Total Complexity | 9 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class Authors extends Model |
||
6 | { |
||
7 | /** |
||
8 | * Hold cherry picked list of authors. |
||
9 | * |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $list = []; |
||
13 | |||
14 | /** |
||
15 | * Add unknown authors to the current list. |
||
16 | * |
||
17 | * @param $authors |
||
18 | * @return array |
||
19 | */ |
||
20 | public function add(array $authors): array |
||
21 | { |
||
22 | if (($count = count($authors)) !== ($listCount = count($this->list))) { |
||
23 | if ($count > $listCount) { |
||
24 | return $this->list = $authors; |
||
25 | } |
||
26 | |||
27 | return $this->list; |
||
28 | } |
||
29 | |||
30 | for ($i = 0; $i < $count; ++$i) { |
||
31 | $this->addUnknownAttributes($authors, $i); |
||
32 | } |
||
33 | |||
34 | return $this->list; |
||
35 | } |
||
36 | |||
37 | protected function addUnknownAttributes($authors, $i) |
||
45 | } |
||
46 | } |
||
49 |