| Total Complexity | 9 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | trait UserAttributesTrait |
||
| 20 | { |
||
| 21 | private Collection $attributes; |
||
| 22 | |||
| 23 | public function getAttributes(): Collection |
||
| 24 | { |
||
| 25 | return $this->attributes; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function getAttributeValue(string $name): string |
||
| 31 | } |
||
| 32 | |||
| 33 | public function setAttributes(ArrayCollection $attributes): self |
||
| 34 | { |
||
| 35 | $this->attributes = $attributes; |
||
| 36 | |||
| 37 | return $this; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param mixed $value |
||
| 42 | */ |
||
| 43 | public function setAttribute(string $name, $value): self |
||
| 44 | { |
||
| 45 | if (isset($this->attributes[$name])) { |
||
| 46 | $this->attributes[$name]->setValue($value); |
||
| 47 | } else { |
||
| 48 | $this->attributes[$name] = new UserAttribute($this, $name, $value); |
||
| 49 | } |
||
| 50 | |||
| 51 | return $this; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function delAttribute(string $name): self |
||
| 55 | { |
||
| 56 | if (isset($this->attributes[$name])) { |
||
| 57 | $this->attributes->remove($name); |
||
| 58 | } |
||
| 59 | |||
| 60 | return $this; |
||
| 61 | } |
||
| 62 | |||
| 63 | public function hasAttribute(string $name): bool |
||
| 66 | } |
||
| 67 | } |
||
| 68 |