mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-23 17:22:41 +01:00
Fix bugs and include Composer autoloader to example.php
This commit is contained in:
parent
1b068456c1
commit
f5c075f02d
@ -5,10 +5,10 @@ namespace DesignPatterns\More\EAV;
|
||||
/**
|
||||
* Class Attribute
|
||||
*/
|
||||
class Attribute implements ValueInterface
|
||||
class Attribute implements ValueAccessInterface
|
||||
{
|
||||
/**
|
||||
* @var Value[]|ValueInterface[]|array
|
||||
* @var array|Value[]|ValueInterface[]
|
||||
*/
|
||||
private $values = [];
|
||||
|
||||
@ -18,7 +18,7 @@ class Attribute implements ValueInterface
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @return Value[]|ValueInterface[]|array
|
||||
* @return array|Value[]|ValueInterface[]
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
|
@ -5,10 +5,10 @@ namespace DesignPatterns\More\EAV;
|
||||
/**
|
||||
* Class Entity
|
||||
*/
|
||||
class Entity implements ValueInterface
|
||||
class Entity implements ValueAccessInterface
|
||||
{
|
||||
/**
|
||||
* @var Value[]|ValueInterface[]|array
|
||||
* @var array|Value[]|ValueInterface[]
|
||||
*/
|
||||
private $values = [];
|
||||
|
||||
@ -18,7 +18,7 @@ class Entity implements ValueInterface
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @return Value[]|ValueInterface[]|array
|
||||
* @return array|Value[]|ValueInterface[]
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ namespace DesignPatterns\More\EAV;
|
||||
/**
|
||||
* Class Value
|
||||
*/
|
||||
class Value
|
||||
class Value implements ValueInterface
|
||||
{
|
||||
/**
|
||||
* @var Attribute
|
||||
@ -17,6 +17,9 @@ class Value
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @param Attribute $attribute
|
||||
*/
|
||||
public function __construct(Attribute $attribute)
|
||||
{
|
||||
$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
|
||||
{
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @param Value|ValueInterface $value
|
||||
*/
|
||||
public function removeValue(ValueInterface $value);
|
||||
public function getAttribute();
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
use DesignPatterns\More\EAV\Entity;
|
||||
use DesignPatterns\More\EAV\Attribute;
|
||||
use DesignPatterns\More\EAV\Value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user