mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 20:20:15 +02:00
Fix bugs and include Composer autoloader to example.php
This commit is contained in:
@@ -5,10 +5,10 @@ namespace DesignPatterns\More\EAV;
|
|||||||
/**
|
/**
|
||||||
* Class Attribute
|
* Class Attribute
|
||||||
*/
|
*/
|
||||||
class Attribute implements ValueInterface
|
class Attribute implements ValueAccessInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Value[]|ValueInterface[]|array
|
* @var array|Value[]|ValueInterface[]
|
||||||
*/
|
*/
|
||||||
private $values = [];
|
private $values = [];
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ class Attribute implements ValueInterface
|
|||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Value[]|ValueInterface[]|array
|
* @return array|Value[]|ValueInterface[]
|
||||||
*/
|
*/
|
||||||
public function getValues()
|
public function getValues()
|
||||||
{
|
{
|
||||||
|
@@ -5,10 +5,10 @@ namespace DesignPatterns\More\EAV;
|
|||||||
/**
|
/**
|
||||||
* Class Entity
|
* Class Entity
|
||||||
*/
|
*/
|
||||||
class Entity implements ValueInterface
|
class Entity implements ValueAccessInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Value[]|ValueInterface[]|array
|
* @var array|Value[]|ValueInterface[]
|
||||||
*/
|
*/
|
||||||
private $values = [];
|
private $values = [];
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ class Entity implements ValueInterface
|
|||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Value[]|ValueInterface[]|array
|
* @return array|Value[]|ValueInterface[]
|
||||||
*/
|
*/
|
||||||
public function getValues()
|
public function getValues()
|
||||||
{
|
{
|
||||||
|
@@ -5,7 +5,7 @@ namespace DesignPatterns\More\EAV;
|
|||||||
/**
|
/**
|
||||||
* Class Value
|
* Class Value
|
||||||
*/
|
*/
|
||||||
class Value
|
class Value implements ValueInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Attribute
|
* @var Attribute
|
||||||
@@ -17,6 +17,9 @@ class Value
|
|||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Attribute $attribute
|
||||||
|
*/
|
||||||
public function __construct(Attribute $attribute)
|
public function __construct(Attribute $attribute)
|
||||||
{
|
{
|
||||||
$attribute->addValue($this);
|
$attribute->addValue($this);
|
||||||
|
24
More/EAV/ValueAccessInterface.php
Normal file
24
More/EAV/ValueAccessInterface.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DesignPatterns\More\EAV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface ValueAccessInterface
|
||||||
|
*/
|
||||||
|
interface ValueAccessInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return Value[]|ValueInterface[]|array
|
||||||
|
*/
|
||||||
|
public function getValues();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Value|ValueInterface $value
|
||||||
|
*/
|
||||||
|
public function addValue(ValueInterface $value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Value|ValueInterface $value
|
||||||
|
*/
|
||||||
|
public function removeValue(ValueInterface $value);
|
||||||
|
}
|
@@ -8,17 +8,12 @@ namespace DesignPatterns\More\EAV;
|
|||||||
interface ValueInterface
|
interface ValueInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return Value[]|ValueInterface[]|array
|
* @param Attribute $attribute
|
||||||
*/
|
*/
|
||||||
public function getValues();
|
public function __construct(Attribute $attribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Value|ValueInterface $value
|
* @return Attribute
|
||||||
*/
|
*/
|
||||||
public function addValue(ValueInterface $value);
|
public function getAttribute();
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Value|ValueInterface $value
|
|
||||||
*/
|
|
||||||
public function removeValue(ValueInterface $value);
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require '../../vendor/autoload.php';
|
||||||
|
|
||||||
use DesignPatterns\More\EAV\Entity;
|
use DesignPatterns\More\EAV\Entity;
|
||||||
use DesignPatterns\More\EAV\Attribute;
|
use DesignPatterns\More\EAV\Attribute;
|
||||||
use DesignPatterns\More\EAV\Value;
|
use DesignPatterns\More\EAV\Value;
|
||||||
|
Reference in New Issue
Block a user