Total Complexity | 10 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class SimpleBillRepository implements BillRepositoryInterface |
||
18 | { |
||
19 | protected $bills = []; |
||
20 | |||
21 | public function findByIds(array $ids): array |
||
22 | { |
||
23 | $bills = []; |
||
24 | foreach ($ids as $id) { |
||
25 | if (empty($this->bills[$id])) { |
||
26 | continue; |
||
27 | } |
||
28 | $bills[$id] = $this->bills[$id]; |
||
29 | } |
||
30 | |||
31 | return $bills; |
||
32 | } |
||
33 | |||
34 | public function save(BillInterface $bill) |
||
35 | { |
||
36 | $this->bills[$bill->getUniqueString()] = $bill; |
||
37 | |||
38 | return $bill->getId(); |
||
39 | } |
||
40 | |||
41 | public function findByUniqueness(array $bills): array |
||
42 | { |
||
43 | $found = []; |
||
44 | foreach ($this->bills as $bill) { |
||
45 | foreach ($bills as $one) { |
||
46 | if ( |
||
47 | !$bill->getType()->equals($one->getType()) || |
||
48 | !$bill->getTarget()->equals($one->getTarget()) |
||
49 | ) { |
||
50 | continue; |
||
51 | } |
||
52 | $found[] = $bill; |
||
53 | } |
||
54 | } |
||
55 | |||
56 | return $found; |
||
57 | } |
||
58 | |||
59 | public function findAll(Specification $specification): array |
||
60 | { |
||
61 | return $this->bills; |
||
62 | } |
||
64 |