<?php
class BaseArticle
{
protected $content;
protected $article = null;
public function __construct($content)
{
$this->content = $content;
}
public function decorator(){
return $this->content;
}
}
# 装饰
class SeoArticle extends BaseArticle
{
public function __construct(BaseArticle $article){
$this->article = $article;
$this->decorator();
}
public function decorator(){
return $this->content = $this->article->decorator() . 'SEO关键词';
}
}
$base = new SeoArticle(new BaseArticle('好好学习'));
echo $base->decorator();