Completed
Push — update_docs ( 6b821b )
by Laurent
128:10 queued 119:52
created

Supplier   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 118
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Tests 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 Domain\Model\Supplier;
15
16
use Domain\Model\Common\Entities\FamilyLog;
17
use Domain\Model\Common\VO\ContactAddress;
18
use Domain\Model\Common\VO\EmailField;
19
use Domain\Model\Common\VO\NameField;
20
use Domain\Model\Common\VO\PhoneField;
21
use Domain\Model\Contact;
22
23
final class Supplier extends Contact
24
{
25
    protected string $uuid;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
26
    private FamilyLog $familyLog;
27
    private int $delayDelivery;
28
    private array $orderDays;
29
    private bool $active;
30
31
    public function __construct(
32
        SupplierUuid $uuid,
33
        NameField $name,
34
        ContactAddress $address,
35
        PhoneField $phone,
36
        PhoneField $facsimile,
37
        EmailField $email,
38
        string $contact,
39
        PhoneField $cellphone,
40
        FamilyLog $familyLog,
41
        int $delayDeliv,
42
        array $orderDays,
43
        bool $active = true
44
    ) {
45
        parent::__construct(
46
            $uuid,
47
            $name,
48
            $address,
49
            $phone,
50
            $facsimile,
51
            $email,
52
            $contact,
53
            $cellphone
54
        );
55
        $this->familyLog = $familyLog;
56
        $this->delayDelivery = $delayDeliv;
57
        $this->orderDays = $orderDays;
58
        $this->slug = $name->slugify();
59
        $this->active = $active;
60
    }
61
62
    public static function create(
63
        SupplierUuid $uuid,
64
        NameField $name,
65
        string $address,
66
        string $zipCode,
67
        string $town,
68
        string $country,
69
        PhoneField $phone,
70
        PhoneField $facsimile,
71
        EmailField $email,
72
        string $contact,
73
        PhoneField $gsm,
74
        FamilyLog $familyLog,
75
        int $delayDelivery,
76
        array $orderDays,
77
        bool $active = true
78
    ): self {
79
        return new self(
80
            $uuid,
81
            $name,
82
            ContactAddress::fromString($address, $zipCode, $town, $country),
83
            $phone,
84
            $facsimile,
85
            $email,
86
            $contact,
87
            $gsm,
88
            $familyLog,
89
            $delayDelivery,
90
            $orderDays,
91
            $active
92
        );
93
    }
94
95
    public function name(): string
96
    {
97
        return $this->name;
98
    }
99
100
    public function renameSupplier(NameField $name): void
101
    {
102
        $this->name = $name->getValue();
103
        $this->slug = $name->slugify();
104
    }
105
106
    public function uuid(): string
107
    {
108
        return $this->uuid;
109
    }
110
111
    public function familyLog(): FamilyLog
112
    {
113
        return $this->familyLog;
114
    }
115
116
    public function setFamilyLog(FamilyLog $familyLog): void
117
    {
118
        $this->familyLog = $familyLog;
119
    }
120
121
    public function delayDelivery(): int
122
    {
123
        return $this->delayDelivery;
124
    }
125
126
    public function setDelayDelivery(int $delayDelivery): void
127
    {
128
        $this->delayDelivery = $delayDelivery;
129
    }
130
131
    public function getOrderDays(): array
132
    {
133
        return $this->orderDays;
134
    }
135
136
    public function setOrderDays(array $orderDays): void
137
    {
138
        $this->orderDays = $orderDays;
139
    }
140
141
    public function isActive(): bool
142
    {
143
        return $this->active;
144
    }
145
146
    public function setActive(bool $active): void
147
    {
148
        $this->active = $active;
149
    }
150
151
    public function getSlug(): string
152
    {
153
        return $this->slug;
154
    }
155
156
    public function setSlug(string $slug): void
157
    {
158
        $this->slug = $slug;
159
    }
160
}
161