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

EnterInventory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 4
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