Supplier::fromModel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 19
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 23
rs 9.6333
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 extends Contact
24
{
25
    /**
26
     * @ORM\Column(type="string", name="family_log", nullable=false)
27
     */
28
    private string $familyLog;
29
30
    /**
31
     * @ORM\Column(type="integer", name="delay_delivery", nullable=false)
32
     */
33
    private int $delayDelivery;
34
35
    /**
36
     * @ORM\Column(type="array", name="order_days", nullable=false)
37
     */
38
    private array $orderDays;
39
40
    /**
41
     * @ORM\Column(type="boolean", name="active", nullable=false)
42
     */
43
    private bool $active;
44
45
    public function __construct(Contact $contact, string $familyLog, int $delayDelivery, array $orderDays, bool $active)
46
    {
47
        parent::__construct(
48
            $contact->uuid,
49
            $contact->companyName,
50
            $contact->address,
51
            $contact->zipCode,
52
            $contact->town,
53
            $contact->country,
54
            $contact->phone,
55
            $contact->facsimile,
56
            $contact->email,
57
            $contact->contactName,
58
            $contact->cellphone,
59
            $contact->slug
60
        );
61
        $this->familyLog = $familyLog;
62
        $this->delayDelivery = $delayDelivery;
63
        $this->orderDays = $orderDays;
64
        $this->active = $active;
65
    }
66
67
    public static function fromModel(SupplierModel $supplier): self
68
    {
69
        $contact = new Contact(
70
            $supplier->uuid(),
71
            $supplier->companyName(),
72
            $supplier->address(),
73
            $supplier->zipCode(),
74
            $supplier->town(),
75
            $supplier->country(),
76
            $supplier->phone(),
77
            $supplier->facsimile(),
78
            $supplier->email(),
79
            $supplier->contactName(),
80
            $supplier->cellphone(),
81
            $supplier->slug()
82
        );
83
84
        return new self(
85
            $contact,
86
            $supplier->familyLog(),
87
            $supplier->delayDelivery(),
88
            $supplier->orderDays(),
89
            $supplier->isActive()
90
        );
91
    }
92
93
    public function getFamilyLog(): string
94
    {
95
        return $this->familyLog;
96
    }
97
98
    public function setFamilyLog(string $familyLog): self
99
    {
100
        $this->familyLog = $familyLog;
101
102
        return $this;
103
    }
104
105
    public function getDelayDelivery(): int
106
    {
107
        return $this->delayDelivery;
108
    }
109
110
    public function setDelayDelivery(int $delayDelivery): self
111
    {
112
        $this->delayDelivery = $delayDelivery;
113
114
        return $this;
115
    }
116
117
    public function getOrderDays(): array
118
    {
119
        return $this->orderDays;
120
    }
121
122
    public function setOrderDays(array $orderDays): self
123
    {
124
        $this->orderDays = $orderDays;
125
126
        return $this;
127
    }
128
129
    public function isActive(): bool
130
    {
131
        return $this->active;
132
    }
133
134
    public function setActive(bool $active): self
135
    {
136
        $this->active = $active;
137
138
        return $this;
139
    }
140
}
141