PHP
- 2 ответа
- 0 вопросов
0
Вклад в тег
interface IDecorable {
/**
* @return IDecorable
*/
removeDecorator(IDecorable $decorator);
}
//....
/**
* @return IDecorable
*/
removeDecorator(IDecorable $decorator) {
return $this;
}
//...
//....
/**
* @var IDecorator
*/
private $decorableObject;
/**
* @return IDecorable
*/
removeDecorator(IDecorable $decorator) {
if($decorator == $this) {
return $this->decorableObject;
}
$decorable = $this->decorableObject->removeDecorator($decorator);
if($decorable != $this->decoratedObject) {
$this->decoratedObject = $decorable;
}
return $this;
}
//...
$decorated = $decorated->removeDecorator($decorated);
$decorated = $decorated->removeDecorator($someOtherDecorator);