Completed
Push — test-rewrite ( 6c8480...18b1ba )
by Laurent
01:37
created

EnterInventory::execute()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 4
nc 4
nop 2
1
<?php
2
3
namespace Inventory\Domain\UseCase;
4
5
use Inventory\Domain\Model\Inventory;
6
7
final class EnterInventory
8
{
9
    public function execute(Inventory $inventory, array $data): void
10
    {
11
        $articles = $inventory->articles();
12
13
        foreach ($data as $datum) {
14
            foreach ($articles->toArray() as $article) {
15
                if ($article->label() === $datum['label']) {
16
                    $article->updateStock($datum['stock']);
17
                }
18
            }
19
        }
20
    }
21
}
22