Рубрики Uncategorized Режим декоратора Автор записи Автор: David Wong Дата записи 19.08.2021 Автор оригинала: David Wong. php abstract class Component { abstract public function operation(); } class MyComponent extends Component { public function operation() { Echo: "This is the normal component method < br >"; } } abstract class Decorator extends Component { protected $component; function __construct(Component $component) { $this->component = $component; } public function operation() { $this->component->operation(); } } class MyDecorator extends Decorator { function __construct(Component $component) { parent::__construct($component); } public function addMethod() { Echo: "this is the way to add decorative appliances < br >"; } public function operation() { $this->addMethod(); parent::operation(); } } $component = new MyComponent(); $da = new MyDecorator($component); $da->operation(); Метки decorator, mode ← Быстрые клавиши для phpstorm → Как правильно использовать полиморфизм в laravel php