/** * テキストを小文字にして返す * * @return string **/ public function getText() { $text = parent::getText(); return strtolower($text); }
public function getText() { $str = parent::getText(); $str = mb_convert_kana($str, "RANSKV"); return $str; }
<?php $textType = new TextDecoratorRed(); $td = new TextDecorator(); $td->setText($textType); $type = $td->type(); abstract class base { abstract function type(); } class text extends base { protected $type; public function type() { $this->type['text'] = "这是文字"; return $this->type; } } class TextDecorator extends text { protected $text; public function setText($text) { $this->text = $text; } public function type() { if ($this->text != null) { $this->type = $this->text->type(); }