PHP7 More

This commit is contained in:
Dominik Liebler
2016-09-22 15:51:45 +02:00
parent 2b1de13391
commit 461d612b91
11 changed files with 84 additions and 617 deletions

View File

@@ -11,81 +11,6 @@ where the number of attributes (properties, parameters) that can be used
to describe them is potentially vast, but the number that will actually apply
to a given entity is relatively modest.
Examples
--------
Check full work example in `example.php`_ file.
.. code-block:: php
use DesignPatterns\More\EAV\Entity;
use DesignPatterns\More\EAV\Attribute;
use DesignPatterns\More\EAV\Value;
// Create color attribute
$color = (new Attribute())->setName('Color');
// Create color values
$colorSilver = (new Value($color))->setName('Silver');
$colorGold = (new Value($color))->setName('Gold');
$colorSpaceGrey = (new Value($color))->setName('Space Grey');
// Create memory attribute
$memory = (new Attribute())->setName('Memory');
// Create memory values
$memory4Gb = (new Value($memory))->setName('4GB');
$memory8Gb = (new Value($memory))->setName('8GB');
$memory16Gb = (new Value($memory))->setName('16GB');
// Create storage attribute
$storage = (new Attribute())->setName('Storage');
// Create storage values
$storage128Gb = (new Value($storage))->setName('128GB');
$storage256Gb = (new Value($storage))->setName('256GB');
$storage512Gb = (new Value($storage))->setName('512GB');
$storage1Tb = (new Value($storage))->setName('1TB');
// Create entities with specific values
$mac = (new Entity())
->setName('MacBook')
// colors
->addValue($colorSilver)
->addValue($colorGold)
->addValue($colorSpaceGrey)
// memories
->addValue($memory8Gb)
// storages
->addValue($storage256Gb)
->addValue($storage512Gb)
;
$macAir = (new Entity())
->setName('MacBook Air')
// colors
->addValue($colorSilver)
// memories
->addValue($memory4Gb)
->addValue($memory8Gb)
// storages
->addValue($storage128Gb)
->addValue($storage256Gb)
->addValue($storage512Gb)
;
$macPro = (new Entity())
->setName('MacBook Pro')
// colors
->addValue($colorSilver)
// memories
->addValue($memory8Gb)
->addValue($memory16Gb)
// storages
->addValue($storage128Gb)
->addValue($storage256Gb)
->addValue($storage512Gb)
->addValue($storage1Tb)
;
UML Diagram
-----------
@@ -98,28 +23,32 @@ Code
You can also find these code on `GitHub`_
Entity.php
.. literalinclude:: Entity.php
:language: php
:linenos:
Attribute.php
.. literalinclude:: Attribute.php
:language: php
:linenos:
Value.php
.. literalinclude:: Value.php
:language: php
:linenos:
Test
----
Tests/EntityTest.php
Tests/EAVTest.php
.. literalinclude:: Tests/EntityTest.php
:language: php
:linenos:
Tests/AttributeTest.php
.. literalinclude:: Tests/AttributeTest.php
:language: php
:linenos:
Tests/ValueTest.php
.. literalinclude:: Tests/ValueTest.php
:language: php
:linenos:
.. _`example.php`: https://github.com/domnikl/DesignPatternsPHP/tree/master/More/EAV/example.php
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/More/EAV
.. __: https://en.wikipedia.org/wiki/Entityattributevalue_model