Passed
Pull Request — develop (#169)
by
unknown
03:14 queued 01:21
created

ReadCompany   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A findAll() 0 3 1
A existsWithName() 0 3 1
A findOneByUuid() 0 9 2
A companyExist() 0 3 1
A __construct() 0 3 1
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
21
final class ReadCompany implements ReadCompanyDomain
22
{
23
    private CompanyRepository $companyRepository;
24
25
    public function __construct(CompanyRepository $companyRepository)
26
    {
27
        $this->companyRepository = $companyRepository;
28
    }
29
30
    public function existsWithName(string $name): bool
31
    {
32
        return $this->companyRepository->existsWithName($name);
33
    }
34
35
    public function findOneByUuid(string $uuid): ?Company
36
    {
37
        $company = $this->companyRepository->findOneByUuid($uuid);
38
39
        if (!$company instanceof Company) {
40
            throw new CompanyNotFoundException();
41
        }
42
43
        return $company;
44
    }
45
46
    public function companyExist(): bool
47
    {
48
        return $this->companyRepository->companyExist();
49
    }
50
51
    public function findAll(): array
52
    {
53
        return $this->companyRepository->findAll();
54
    }
55
}
56