Passed
Push — feature/configure_company ( 5f97ab...38f251 )
by Laurent
03:30 queued 10s
created

Supplier   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 125
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 44
c 1
b 1
f 0
dl 0
loc 125
rs 10
wmc 13

13 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 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 28 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\Contact;
17
use Domain\Common\Model\Entities\FamilyLog;
18
use Domain\Common\Model\VO\ContactAddress;
19
use Domain\Common\Model\VO\EmailField;
20
use Domain\Common\Model\VO\NameField;
21
use Domain\Common\Model\VO\PhoneField;
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 $delayDelivery,
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 = $delayDelivery;
57
        $this->orderDays = $orderDays;
58
        $this->active = $active;
59
    }
60
61
    public static function create(
62
        SupplierUuid $uuid,
63
        NameField $name,
64
        string $address,
65
        string $zipCode,
66
        string $town,
67
        string $country,
68
        PhoneField $phone,
69
        PhoneField $facsimile,
70
        EmailField $email,
71
        string $contact,
72
        PhoneField $gsm,
73
        FamilyLog $familyLog,
74
        int $delayDelivery,
75
        array $orderDays,
76
        bool $active = true
77
    ): self {
78
        return new self(
79
            $uuid,
80
            $name,
81
            ContactAddress::fromString($address, $zipCode, $town, $country),
82
            $phone,
83
            $facsimile,
84
            $email,
85
            $contact,
86
            $gsm,
87
            $familyLog,
88
            $delayDelivery,
89
            $orderDays,
90
            $active
91
        );
92
    }
93
94
    public function renameSupplier(NameField $name): void
95
    {
96
        $this->name = $name->getValue();
97
        $this->slug = $name->slugify();
98
    }
99
100
    public function familyLog(): FamilyLog
101
    {
102
        return $this->familyLog;
103
    }
104
105
    public function setFamilyLog(FamilyLog $familyLog): void
106
    {
107
        $this->familyLog = $familyLog;
108
    }
109
110
    public function delayDelivery(): int
111
    {
112
        return $this->delayDelivery;
113
    }
114
115
    public function setDelayDelivery(int $delayDelivery): void
116
    {
117
        $this->delayDelivery = $delayDelivery;
118
    }
119
120
    public function getOrderDays(): array
121
    {
122
        return $this->orderDays;
123
    }
124
125
    public function setOrderDays(array $orderDays): void
126
    {
127
        $this->orderDays = $orderDays;
128
    }
129
130
    public function isActive(): bool
131
    {
132
        return $this->active;
133
    }
134
135
    public function setActive(bool $active): void
136
    {
137
        $this->active = $active;
138
    }
139
140
    public function getSlug(): string
141
    {
142
        return $this->slug;
143
    }
144
145
    public function setSlug(string $slug): void
146
    {
147
        $this->slug = $slug;
148
    }
149
}
150