@@ 24-35 (lines=12) @@ | ||
21 | private $attributes = []; |
|
22 | private $relationships = []; |
|
23 | ||
24 | public function setAttribute($name, $value) |
|
25 | { |
|
26 | if (! $this->validateField($name)) { |
|
27 | throw new InvalidArgumentException('Invalid attribute name'); |
|
28 | } |
|
29 | ||
30 | if (isset($this->relationships[$name])) { |
|
31 | throw new LogicException("Field $name already exists in relationships"); |
|
32 | } |
|
33 | ||
34 | $this->attributes[$name] = $value; |
|
35 | } |
|
36 | ||
37 | public function setRelationship($name, Relationship $value) |
|
38 | { |
|
@@ 37-48 (lines=12) @@ | ||
34 | $this->attributes[$name] = $value; |
|
35 | } |
|
36 | ||
37 | public function setRelationship($name, Relationship $value) |
|
38 | { |
|
39 | if (! $this->validateField($name)) { |
|
40 | throw new InvalidArgumentException('Invalid relationship name'); |
|
41 | } |
|
42 | ||
43 | if (isset($this->attributes[$name])) { |
|
44 | throw new LogicException("Field $name already exists in attributes"); |
|
45 | } |
|
46 | ||
47 | $this->relationships[$name] = $value; |
|
48 | } |
|
49 | ||
50 | public function jsonSerialize() |
|
51 | { |