| 1 | <?php |
||
| 8 | class Relation |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var string The link "rel" attribute |
||
| 12 | */ |
||
| 13 | private $name; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string|Route|null |
||
| 17 | */ |
||
| 18 | private $href; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var array Extra link attributes |
||
| 22 | */ |
||
| 23 | private $attributes; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var Embedded|null |
||
| 27 | */ |
||
| 28 | private $embedded; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var Exclusion|null |
||
| 32 | */ |
||
| 33 | private $exclusion; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $name |
||
| 37 | * @param string|Route $href |
||
| 38 | * @param Embedded|string|mixed $embedded |
||
| 39 | * @param array $attributes |
||
| 40 | * @param Exclusion $exclusion |
||
| 41 | */ |
||
| 42 | public function __construct($name, $href = null, $embedded = null, array $attributes = array(), Exclusion $exclusion = null) |
||
| 43 | { |
||
| 44 | if (null !== $embedded && !$embedded instanceof Embedded) { |
||
| 45 | $embedded = new Embedded($embedded); |
||
| 46 | } |
||
| 47 | |||
| 48 | if (null === !$href && null === $embedded) { |
||
| 49 | throw new \InvalidArgumentException('$href and $embedded cannot be both null.'); |
||
| 50 | } |
||
| 51 | |||
| 52 | $this->name = $name; |
||
| 53 | $this->href = $href; |
||
| 54 | $this->embedded = $embedded; |
||
| 55 | $this->attributes = $attributes; |
||
| 56 | $this->exclusion = $exclusion; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | public function getName() |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @return Route|string|null |
||
| 69 | */ |
||
| 70 | public function getHref() |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return array |
||
| 77 | */ |
||
| 78 | public function getAttributes() |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @return Embedded|null |
||
| 85 | */ |
||
| 86 | public function getEmbedded() |
||
| 87 | { |
||
| 88 | return $this->embedded; |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @return Exclusion|null |
||
| 93 | */ |
||
| 94 | public function getExclusion() |
||
| 98 | } |
||
| 99 |