Passed
Pull Request — develop (#118)
by Laurent
05:08 queued 02:44
created

Supplier   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 131
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 14
eloc 46
dl 0
loc 131
c 0
b 0
f 0
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A getSlug() 0 3 1
A setFamilyLog() 0 3 1
A setSlug() 0 3 1
A setDelayDelivery() 0 3 1
A delayDelivery() 0 3 1
A familyLog() 0 3 1
A uuid() 0 3 1
A setActive() 0 3 1
A getOrderDays() 0 3 1
A create() 0 30 1
A isActive() 0 3 1
A renameSupplier() 0 4 1
A __construct() 0 29 1
A setOrderDays() 0 3 1
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 Domain\Supplier\Model;
15
16
use Domain\Common\Model\Entities\FamilyLog;
17
use Domain\Common\Model\VO\ContactAddress;
18
use Domain\Common\Model\VO\EmailField;
19
use Domain\Common\Model\VO\NameField;
20
use Domain\Common\Model\VO\PhoneField;
21
use Domain\Common\Model\Contact;
22
23
final class Supplier extends Contact
24
{
25
    protected string $uuid;
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 renameSupplier(NameField $name): void
96
    {
97
        $this->name = $name->getValue();
98
        $this->slug = $name->slugify();
99
    }
100
101
    public function uuid(): string
102
    {
103
        return $this->uuid;
104
    }
105
106
    public function familyLog(): FamilyLog
107
    {
108
        return $this->familyLog;
109
    }
110
111
    public function setFamilyLog(FamilyLog $familyLog): void
112
    {
113
        $this->familyLog = $familyLog;
114
    }
115
116
    public function delayDelivery(): int
117
    {
118
        return $this->delayDelivery;
119
    }
120
121
    public function setDelayDelivery(int $delayDelivery): void
122
    {
123
        $this->delayDelivery = $delayDelivery;
124
    }
125
126
    public function getOrderDays(): array
127
    {
128
        return $this->orderDays;
129
    }
130
131
    public function setOrderDays(array $orderDays): void
132
    {
133
        $this->orderDays = $orderDays;
134
    }
135
136
    public function isActive(): bool
137
    {
138
        return $this->active;
139
    }
140
141
    public function setActive(bool $active): void
142
    {
143
        $this->active = $active;
144
    }
145
146
    public function getSlug(): string
147
    {
148
        return $this->slug;
149
    }
150
151
    public function setSlug(string $slug): void
152
    {
153
        $this->slug = $slug;
154
    }
155
}
156