mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-11 01:14:01 +02:00
a REAL abstract factory not a helper-like full of static
This commit is contained in:
23
AbstractFactory/Json/Picture.php
Normal file
23
AbstractFactory/Json/Picture.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* DesignPatternPHP
|
||||
*/
|
||||
|
||||
namespace DesignPatterns\AbstractFactory\Json;
|
||||
|
||||
use DesignPatterns\AbstractFactory\Picture as BasePicture;
|
||||
|
||||
/**
|
||||
* Picture is a concrete image for JSON rendering
|
||||
*/
|
||||
class Picture extends BasePicture
|
||||
{
|
||||
|
||||
// some crude rendering from JSON output
|
||||
public function render()
|
||||
{
|
||||
return json_encode(array('title' => $this->_name, 'path' => $this->_path));
|
||||
}
|
||||
|
||||
}
|
22
AbstractFactory/Json/Text.php
Normal file
22
AbstractFactory/Json/Text.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* DesignPatternPHP
|
||||
*/
|
||||
|
||||
namespace DesignPatterns\AbstractFactory\Json;
|
||||
|
||||
use DesignPatterns\AbstractFactory\Text as BaseText;
|
||||
|
||||
/**
|
||||
* Text is a text component with a JSON rendering
|
||||
*/
|
||||
class Text extends BaseText
|
||||
{
|
||||
|
||||
public function render()
|
||||
{
|
||||
return json_encode(array('content' => $this->_text));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user