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