echo tagins("br") . tagins("br"); $patternBook = new Book("Gamma, Helm, Johnson, and Vlissides", "Design Patterns"); $decorator = new BookTitleDecorator($patternBook); $starDecorator = new BookTitleStarDecorator($decorator); $exclaimDecorator = new BookTitleExclaimDecorator($decorator); echo "showing title : " . tagins("br"); echo $decorator->showTitle(); echo tagins("br") . tagins("br"); echo "showing title after two exclaims added : " . tagins("br"); $exclaimDecorator->exclaimTitle(); $exclaimDecorator->exclaimTitle(); echo $decorator->showTitle(); echo tagins("br") . tagins("br"); echo "showing title after star added : " . tagins("br"); $starDecorator->starTitle(); echo $decorator->showTitle(); echo tagins("br") . tagins("br"); echo "showing title after reset: " . tagins("br"); echo $decorator->resetTitle(); echo $decorator->showTitle(); echo tagins("br") . tagins("br"); echo tagins("br"); echo "END TESTING DECORATOR PATTERN"; echo tagins("br"); echo tagins("/body"); echo tagins("/html"); //doing this so code can be displayed without breaks function tagins($stuffing) { return "<" . $stuffing . ">"; }
{ $this->btd->title = Str_replace(" ", "*", $this->btd->title); } } writeln('BEGIN TESTING DECORATOR PATTERN'); writeln(''); $patternBook = new Book('Gamma, Helm, Johnson, and Vlissides', 'Design Patterns'); $decorator = new BookTitleDecorator($patternBook); $starDecorator = new BookTitleStarDecorator($decorator); $exclaimDecorator = new BookTitleExclaimDecorator($decorator); writeln('showing title : '); writeln($decorator->showTitle()); writeln(''); writeln('showing title after two exclaims added : '); $exclaimDecorator->exclaimTitle(); $exclaimDecorator->exclaimTitle(); writeln($decorator->showTitle()); writeln(''); writeln('showing title after star added : '); $starDecorator->starTitle(); writeln($decorator->showTitle()); writeln(''); writeln('showing title after reset: '); writeln($decorator->resetTitle()); writeln($decorator->showTitle()); writeln(''); writeln('END TESTING DECORATOR PATTERN'); function writeln($line_in) { echo $line_in . "<br/>"; }