a REAL abstract factory not a helper-like full of static

This commit is contained in:
Trismegiste
2013-05-10 23:54:19 +02:00
parent 3a3937f339
commit eebdbc1dc5
11 changed files with 216 additions and 24 deletions

View File

@@ -0,0 +1,23 @@
<?php
/*
* DesignPatternPHP
*/
namespace DesignPatterns\AbstractFactory\Html;
use DesignPatterns\AbstractFactory\Picture as BasePicture;
/**
* Picture is a concrete image for HTML rendering
*/
class Picture extends BasePicture
{
// some crude rendering from HTML output
public function render()
{
return sprintf('<img src="%s" title="$s"/>', $this->_path, $this->_name);
}
}

View File

@@ -0,0 +1,22 @@
<?php
/*
* DesignPatternPHP
*/
namespace DesignPatterns\AbstractFactory\Html;
use DesignPatterns\AbstractFactory\Text as BaseText;
/**
* Text is a concrete text for HTML rendering
*/
class Text extends BaseText
{
public function render()
{
return "<div>" . htmlspecialchars($this->_text) . '</div>';
}
}