mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-01 12:40:11 +02:00
a REAL abstract factory not a helper-like full of static
This commit is contained in:
23
AbstractFactory/Html/Picture.php
Normal file
23
AbstractFactory/Html/Picture.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
22
AbstractFactory/Html/Text.php
Normal file
22
AbstractFactory/Html/Text.php
Normal 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>';
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user