Passed
Push — orm-management ( 19e760...de38f8 )
by Laurent
01:44
created

Supplier::fromModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 19
nc 1
nop 1
dl 0
loc 23
rs 9.6333
c 0
b 0
f 0
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\Persistence\DoctrineOrm\Entities;
15
16
use Administration\Domain\Supplier\Model\Supplier as SupplierModel;
17
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping 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...
18
19
/**
20
 * @ORM\Table(name="supplier")
21
 * @ORM\Entity(repositoryClass="Administration\Infrastructure\Persistence\DoctrineOrm\Repositories\DoctrineSupplierRepository")
22
 */
23
class Supplier
24
{
25
    /**
26
     * @ORM\Column(type="string", nullable=false)
27
     */
28
    private string $familyLog;
29
30
    /**
31
     * @ORM\Column(type="integer", nullable=false)
32
     */
33
    private int $delayDelivery;
34
35
    /**
36
     * @ORM\Column(type="array", nullable=false)
37
     */
38
    private array $orderDays;
39
40
    /**
41
     * @ORM\Column(type="boolean", nullable=false)
42
     */
43
    private bool $active;
44
45
    /** @ORM\Embedded(class="Contact") */
46
    private Contact $contact;
47
48
    public function __construct(Contact $contact, string $familyLog, int $delayDelivery, array $orderDays, bool $active)
49
    {
50
        $this->contact = $contact;
51
        $this->familyLog = $familyLog;
52
        $this->delayDelivery = $delayDelivery;
53
        $this->orderDays = $orderDays;
54
        $this->active = $active;
55
    }
56
57
    public static function fromModel(SupplierModel $supplier): self
58
    {
59
        $contact = new Contact(
60
            $supplier->uuid(),
61
            $supplier->name(),
62
            $supplier->address(),
63
            $supplier->zipCode(),
64
            $supplier->town(),
65
            $supplier->country(),
66
            $supplier->phone(),
67
            $supplier->facsimile(),
68
            $supplier->email(),
69
            $supplier->contactName(),
70
            $supplier->cellphone(),
71
            $supplier->slug()
72
        );
73
74
        return new self(
75
            $contact,
76
            $supplier->familyLog(),
77
            $supplier->delayDelivery(),
78
            $supplier->orderDays(),
79
            $supplier->isActive()
80
        );
81
    }
82
83
    public function getFamilyLog(): string
84
    {
85
        return $this->familyLog;
86
    }
87
88
    public function setFamilyLog(string $familyLog): self
89
    {
90
        $this->familyLog = $familyLog;
91
92
        return $this;
93
    }
94
95
    public function getDelayDelivery(): int
96
    {
97
        return $this->delayDelivery;
98
    }
99
100
    public function setDelayDelivery(int $delayDelivery): self
101
    {
102
        $this->delayDelivery = $delayDelivery;
103
104
        return $this;
105
    }
106
107
    public function getOrderDays(): array
108
    {
109
        return $this->orderDays;
110
    }
111
112
    public function setOrderDays(array $orderDays): self
113
    {
114
        $this->orderDays = $orderDays;
115
116
        return $this;
117
    }
118
119
    public function isActive(): bool
120
    {
121
        return $this->active;
122
    }
123
124
    public function setActive(bool $active): self
125
    {
126
        $this->active = $active;
127
128
        return $this;
129
    }
130
}
131