Passed
Push — develop ( e3219b...3a1d34 )
by Laurent
01:38
created

ReadCompany::findOneByUuid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Company\Infrastructure\Storage\Company;
15
16
use Company\Domain\Exception\CompanyNotFoundException;
17
use Company\Domain\Model\Company as CompanyModel;
18
use Company\Domain\Storage\Company\ReadCompany as ReadCompanyDomain;
19
use Company\Infrastructure\Doctrine\Entity\Company;
20
use Company\Infrastructure\Doctrine\Repository\CompanyRepository;
21
use Core\Domain\Common\Model\VO\ResourceUuid;
22
23
class ReadCompany implements ReadCompanyDomain
24
{
25
    private CompanyRepository $companyRepository;
26
27
    public function __construct(CompanyRepository $companyRepository)
28
    {
29
        $this->companyRepository = $companyRepository;
30
    }
31
32
    public function findOneByUuid(string $uuid): CompanyModel
33
    {
34
        $company = $this->companyRepository->findOneByUuid(ResourceUuid::fromString($uuid));
35
36
        if (!$company instanceof Company) {
37
            throw new CompanyNotFoundException();
38
        }
39
40
        return $company->toModel();
41
    }
42
43
    public function companyExist(): bool
44
    {
45
        return $this->companyRepository->companyExist();
46
    }
47
48
    public function findAll(): array
49
    {
50
        return $this->companyRepository->findAll();
51
    }
52
}
53