Passed
Push — develop ( 78e2d5...9c7a10 )
by Laurent
02:42 queued 01:21
created

Supplier::setDelayDelivery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
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 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\Domain\Supplier\Model;
15
16
use Core\Domain\Common\Model\Contact;
17
use Core\Domain\Common\Model\Dependent\FamilyLog;
18
use Core\Domain\Common\Model\VO\ContactUuid;
19
use Core\Domain\Common\Model\VO\EmailField;
20
use Core\Domain\Common\Model\VO\NameField;
21
use Core\Domain\Common\Model\VO\PhoneField;
22
23
final class Supplier extends Contact
24
{
25
    protected string $uuid;
26
    private string $familyLog;
27
    private int $delayDelivery;
28
    private array $orderDays;
29
    private bool $active;
30
31
    public function __construct(
32
        ContactUuid $uuid,
33
        NameField $name,
34
        string $address,
35
        string $zipCode,
36
        string $town,
37
        string $country,
38
        PhoneField $phone,
39
        PhoneField $facsimile,
40
        EmailField $email,
41
        string $contact,
42
        PhoneField $cellphone,
43
        FamilyLog $familyLog,
44
        int $delayDelivery,
45
        array $orderDays,
46
        bool $active = true
47
    ) {
48
        parent::__construct(
49
            $uuid,
50
            $name,
51
            $address,
52
            $zipCode,
53
            $town,
54
            $country,
55
            $phone,
56
            $facsimile,
57
            $email,
58
            $contact,
59
            $cellphone
60
        );
61
        $this->familyLog = $familyLog->path();
62
        $this->delayDelivery = $delayDelivery;
63
        $this->orderDays = $orderDays;
64
        $this->active = $active;
65
    }
66
67
    public static function create(
68
        ContactUuid $uuid,
69
        NameField $name,
70
        string $address,
71
        string $zipCode,
72
        string $town,
73
        string $country,
74
        PhoneField $phone,
75
        PhoneField $facsimile,
76
        EmailField $email,
77
        string $contact,
78
        PhoneField $gsm,
79
        FamilyLog $familyLog,
80
        int $delayDelivery,
81
        array $orderDays,
82
        bool $active = true
83
    ): self {
84
        return new self(
85
            $uuid,
86
            $name,
87
            $address,
88
            $zipCode,
89
            $town,
90
            $country,
91
            $phone,
92
            $facsimile,
93
            $email,
94
            $contact,
95
            $gsm,
96
            $familyLog,
97
            $delayDelivery,
98
            $orderDays,
99
            $active
100
        );
101
    }
102
103
    public function renameSupplier(NameField $name): void
104
    {
105
        $this->name = $name->getValue();
106
        $this->slug = $name->slugify();
107
    }
108
109
    public function familyLog(): string
110
    {
111
        return $this->familyLog;
112
    }
113
114
    public function reassignFamilyLog(FamilyLog $familyLog): void
115
    {
116
        $this->familyLog = $familyLog->path();
117
    }
118
119
    public function delayDelivery(): int
120
    {
121
        return $this->delayDelivery;
122
    }
123
124
    public function changeDelayDelivery(int $delayDelivery): void
125
    {
126
        $this->delayDelivery = $delayDelivery;
127
    }
128
129
    public function orderDays(): array
130
    {
131
        return $this->orderDays;
132
    }
133
134
    public function reassignOrderDays(array $orderDays): void
135
    {
136
        $this->orderDays = $orderDays;
137
    }
138
139
    public function isActive(): bool
140
    {
141
        return $this->active;
142
    }
143
144
    public function delete(): void
145
    {
146
        $this->active = false;
147
    }
148
149
    public function getSlug(): string
150
    {
151
        return $this->slug;
152
    }
153
154
    public function setSlug(string $slug): void
155
    {
156
        $this->slug = $slug;
157
    }
158
}
159