Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | public function __invoke(CreateCompany $command): void |
||
33 | { |
||
34 | if ($this->repository->companyExist()) { |
||
35 | throw new \DomainException('A company is already create.'); |
||
36 | } |
||
37 | if ($this->repository->existsWithName($command->name()->getValue())) { |
||
38 | throw new \DomainException("Company with name: {$command->name()->getValue()} already exists."); |
||
39 | } |
||
40 | |||
41 | $company = $this->factory->create($command); |
||
42 | |||
43 | $this->repository->add($company); |
||
44 | } |
||
46 |