| Total Complexity | 6 |
| Total Lines | 78 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | trait HasAttributes |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * The "attributes" object. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $attributes; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Set all the attributes. |
||
| 23 | * |
||
| 24 | * @param array $attributes |
||
| 25 | * |
||
| 26 | * @return static |
||
| 27 | */ |
||
| 28 | 30 | public function setAttributes(array $attributes) |
|
| 29 | { |
||
| 30 | 30 | $this->attributes = $attributes; |
|
| 31 | |||
| 32 | 30 | return $this; |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Get all the attributes. |
||
| 37 | * |
||
| 38 | * @return array|null |
||
| 39 | */ |
||
| 40 | 15 | public function getAttributes(): ?array |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Add many attributes. |
||
| 47 | * |
||
| 48 | * @param array $attributes |
||
| 49 | * |
||
| 50 | * @return static |
||
| 51 | */ |
||
| 52 | 3 | public function addAttributes(array $attributes) |
|
| 53 | { |
||
| 54 | 3 | foreach ($attributes as $name => $value) { |
|
| 55 | 3 | $this->addAttribute($name, $value); |
|
| 56 | } |
||
| 57 | |||
| 58 | 3 | return $this; |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Add a single attribute. |
||
| 63 | * |
||
| 64 | * @param string $name |
||
| 65 | * @param mixed $value |
||
| 66 | * |
||
| 67 | * @return static |
||
| 68 | */ |
||
| 69 | 6 | public function addAttribute(string $name, $value) |
|
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Fill the "attributes" object with fake members and values. |
||
| 78 | * |
||
| 79 | * @param integer $count The number of attributes to generate. |
||
| 80 | * |
||
| 81 | * @return static |
||
| 82 | */ |
||
| 83 | 18 | public function fakeAttributes(int $count = 5) |
|
| 90 | } |
||
| 91 | } |
||
| 92 |