Passed
Pull Request — develop (#172)
by
unknown
03:45 queued 01:33
created

GetCompanyHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 2
A __construct() 0 4 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\Application\Company\Handler;
15
16
use Company\Application\Company\DTO\OutputCompany;
17
use Company\Application\Company\Factory\CreateOutputCompany;
18
use Company\Application\Company\Query\GetCompany;
19
use Company\Domain\Model\Company;
20
use Company\Domain\Storage\Company\ReadCompany;
21
use Core\Domain\Common\Query\QueryHandlerInterface;
22
23
class GetCompanyHandler implements QueryHandlerInterface
24
{
25
    private ReadCompany $readCompany;
26
    private CreateOutputCompany $createOutputSettings;
27
28
    public function __construct(ReadCompany $readCompany, CreateOutputCompany $createOutputSettings)
29
    {
30
        $this->readCompany = $readCompany;
31
        $this->createOutputSettings = $createOutputSettings;
32
    }
33
34
    public function __invoke(GetCompany $query): ?OutputCompany
35
    {
36
        $company = $this->readCompany->findOneByUuid($query->uuid());
37
38
        if (!$company instanceof Company) {
0 ignored issues
show
introduced by
$company is always a sub-type of Company\Domain\Model\Company.
Loading history...
39
            return null;
40
        }
41
42
        return $this->createOutputSettings->create($company);
43
    }
44
}
45