文章类获取初始的文章内容

class Art
{
    protected $content = null;

    public function __construct($content) {
        $this->content = $content;
    }

    public function decorator() {
        return $this->content;
    }
}

定义装饰文章类
art 参数 保存着 文章类的初始化对象

class ArtDesc extends Art
{
    protected $art = null;

    public function __construct($art)
    {
        $this->art = $art;
    }

    public function decorator() {

    }
}

SEO类和AD类继承装饰器类达到对文章内容的添加的效果

class SeoArt extends ArtDesc
{
    public function decorator()
    {
        return $this->art->decorator().'SEO KEYWORDS';
    }
}

class AdArt extends  ArtDesc {
    public function decorator() {
        return $this->art->decorator().'广告内容';
    }
}

调用
将初始化文章基础对象 传入装饰器类

$art = new Art('文章内容');
$art = new SeoArt($art);
$art = new AdArt($art);
echo $art->decorator();