PHP Classes
elePHPant
Icontem

File: example/ClassDecorators/CRUDDecorator.php

Recommend this page to a friend!
  Classes of Aleksandar Zivanovic  >  PHP Decorator Pattern  >  example/ClassDecorators/CRUDDecorator.php  >  Download  
File: example/ClassDecorators/CRUDDecorator.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Decorator Pattern
Implement the decorator pattern using a trait
Author: By
Last change:
Date: 10 months ago
Size: 455 bytes
 

 

Contents

Class file image Download
<?php
/**
 * Author: Aleksandar Zivanovic
 */

namespace App\ClassDecorators;

use
App\Entities\CommentEntity;
use
App\Entities\PostEntity;

class
CRUDDecorator
{
    public static function
create(callable $context, array $data): object
   
{
       
$context(function ($object) use ($data) {
           
var_dump($object->title, $data);
        },
PostEntity::class);

       
$context(function () use ($data) {

        },
CommentEntity::class);
    }
}