| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 31 | public function __invoke(CreateFamilyLog $command): void |
||
| 32 | { |
||
| 33 | $parent = null; |
||
| 34 | $level = 1; |
||
| 35 | if ($this->repository->existWithLabel($command->label()->getValue(), $command->parent())) { |
||
| 36 | throw new \DomainException("FamilyLog with name: {$command->label()->getValue()} already exist!"); |
||
| 37 | } |
||
| 38 | if (null !== $command->parent()) { |
||
| 39 | $parent = $this->repository->findParent($command->parent()); |
||
| 40 | $level = $parent->level() + 1; |
||
| 41 | } |
||
| 42 | |||
| 43 | $familyLog = FamilyLog::create( |
||
| 44 | FamilyLogUuid::generate(), |
||
| 45 | $command->label(), |
||
| 46 | $level, |
||
| 47 | $parent |
||
| 48 | ); |
||
| 49 | |||
| 50 | $this->repository->add($familyLog); |
||
| 51 | } |
||
| 53 |