Passed
Push — develop ( 577144...bf5480 )
by
unknown
01:39
created

ReadCompany::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
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;
15
16
use Company\Domain\Exception\CompanyNotFoundException;
17
use Company\Domain\Storage\ReadCompany as ReadCompanyDomain;
18
use Company\Infrastructure\Doctrine\Entity\Company;
19
use Company\Infrastructure\Doctrine\Repository\CompanyRepository;
20
use Core\Domain\Common\Model\VO\ResourceUuid;
21
22
class ReadCompany implements ReadCompanyDomain
23
{
24
    private CompanyRepository $companyRepository;
25
26
    public function __construct(CompanyRepository $companyRepository)
27
    {
28
        $this->companyRepository = $companyRepository;
29
    }
30
31
    public function existsWithName(string $companyName): bool
32
    {
33
        return $this->companyRepository->existsWithName($companyName);
34
    }
35
36
    public function findOneByUuid(string $uuid): ?Company
37
    {
38
        $company = $this->companyRepository->findOneByUuid(ResourceUuid::fromString($uuid));
39
40
        if (!$company instanceof Company) {
41
            throw new CompanyNotFoundException();
42
        }
43
44
        return $company;
45
    }
46
47
    public function companyExist(): bool
48
    {
49
        return $this->companyRepository->companyExist();
50
    }
51
52
    public function findAll(): array
53
    {
54
        return $this->companyRepository->findAll();
55
    }
56
}
57