Passed
Push — suppliers ( d07ac7...1b3b2e )
by Laurent
01:23
created

DoctrineSupplierFinder::findAllActive()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 21
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 26
rs 9.584
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 Administration\Infrastructure\Finders\DoctrineOrm;
15
16
use Administration\Application\Protocol\Finders\SupplierFinderProtocol;
17
use Administration\Application\Supplier\ReadModel\Suppliers;
18
use Administration\Domain\Supplier\Model\Supplier as SupplierModel;
19
use Administration\Domain\Supplier\Model\VO\SupplierUuid;
20
use Core\Domain\Common\Model\VO\EmailField;
21
use Core\Domain\Common\Model\VO\NameField;
22
use Core\Domain\Common\Model\VO\PhoneField;
23
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
0 ignored issues
show
Bug introduced by
The type Doctrine\Bundle\Doctrine...ServiceEntityRepository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use Doctrine\ORM\NonUniqueResultException;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\NonUniqueResultException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use Doctrine\Persistence\ManagerRegistry;
0 ignored issues
show
Bug introduced by
The type Doctrine\Persistence\ManagerRegistry was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
27
class DoctrineSupplierFinder extends ServiceEntityRepository implements SupplierFinderProtocol
28
{
29
    public function __construct(ManagerRegistry $registry)
30
    {
31
        parent::__construct($registry, SupplierModel::class);
32
    }
33
34
    /**
35
     * @throws NonUniqueResultException
36
     */
37
    public function findOneByUuid(string $uuid): SupplierModel
38
    {
39
        $result = $this->createQueryBuilder('s')
40
            ->where('s.uuid = :uuid')
41
            ->setParameter('uuid', $uuid)
42
            ->getQuery()
43
            ->getOneOrNullResult()
44
        ;
45
46
        return new SupplierModel(
47
            SupplierUuid::fromString($result->getUuid()),
48
            NameField::fromString($result->getName()),
49
            $result->getAddress(),
50
            $result->getZipCode(),
51
            $result->getTown(),
52
            $result->getCountry(),
53
            PhoneField::fromString($result->getPhone()),
54
            PhoneField::fromString($result->getFacsimile()),
55
            EmailField::fromString($result->getEmail()),
56
            $result->getContact(),
57
            PhoneField::fromString($result->getCellphone()),
58
            $result->getFamilyLog(),
59
            $result->getDelayDelivery(),
60
            $result->getOrderDay()
61
        );
62
    }
63
64
    public function findAllActive(): Suppliers
65
    {
66
        $statement = $this->createQueryBuilder('s')
67
            ->getQuery()
68
            ->getResult()
69
        ;
70
71
        return new Suppliers(
72
            ...\array_map(static function (SupplierModel $supplier) {
73
                return new SupplierModel(
74
                    $supplier->uuid(),
0 ignored issues
show
Bug introduced by
$supplier->uuid() of type string is incompatible with the type Core\Domain\Common\Model\VO\ContactUuid expected by parameter $uuid of Administration\Domain\Su...Supplier::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

74
                    /** @scrutinizer ignore-type */ $supplier->uuid(),
Loading history...
75
                    $supplier->name(),
0 ignored issues
show
Bug introduced by
$supplier->name() of type string is incompatible with the type Core\Domain\Common\Model\VO\NameField expected by parameter $name of Administration\Domain\Su...Supplier::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

75
                    /** @scrutinizer ignore-type */ $supplier->name(),
Loading history...
76
                    $supplier->address(),
77
                    $supplier->zipCode(),
78
                    $supplier->town(),
79
                    $supplier->country(),
80
                    $supplier->phone(),
0 ignored issues
show
Bug introduced by
$supplier->phone() of type string is incompatible with the type Core\Domain\Common\Model\VO\PhoneField expected by parameter $phone of Administration\Domain\Su...Supplier::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

80
                    /** @scrutinizer ignore-type */ $supplier->phone(),
Loading history...
81
                    $supplier->facsimile(),
0 ignored issues
show
Bug introduced by
$supplier->facsimile() of type string is incompatible with the type Core\Domain\Common\Model\VO\PhoneField expected by parameter $facsimile of Administration\Domain\Su...Supplier::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

81
                    /** @scrutinizer ignore-type */ $supplier->facsimile(),
Loading history...
82
                    $supplier->email(),
0 ignored issues
show
Bug introduced by
$supplier->email() of type string is incompatible with the type Core\Domain\Common\Model\VO\EmailField expected by parameter $email of Administration\Domain\Su...Supplier::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

82
                    /** @scrutinizer ignore-type */ $supplier->email(),
Loading history...
83
                    $supplier->contact(),
84
                    $supplier->cellphone(),
0 ignored issues
show
Bug introduced by
$supplier->cellphone() of type string is incompatible with the type Core\Domain\Common\Model\VO\PhoneField expected by parameter $cellphone of Administration\Domain\Su...Supplier::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

84
                    /** @scrutinizer ignore-type */ $supplier->cellphone(),
Loading history...
85
                    $supplier->familyLog(),
86
                    $supplier->delayDelivery(),
87
                    $supplier->orderDays()
0 ignored issues
show
Bug introduced by
The method orderDays() does not exist on Administration\Domain\Supplier\Model\Supplier. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

87
                    $supplier->/** @scrutinizer ignore-call */ 
88
                               orderDays()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
                );
89
            }, $statement)
90
        );
91
    }
92
}
93