Article::supplier()   A
last analyzed

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 0
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\Article\Model;
15
16
use Administration\Domain\Article\Model\Dependent\ZoneStorage;
17
use Administration\Domain\Article\Model\VO\ArticleUuid;
18
use Administration\Domain\Article\Model\VO\Packaging;
19
use Administration\Domain\Supplier\Model\Supplier;
20
use Core\Domain\Common\Model\Dependent\FamilyLog;
21
use Core\Domain\Common\Model\Dependent\Taxes;
22
use Core\Domain\Common\Model\VO\NameField;
23
24
final class Article
25
{
26
    private string $uuid;
27
    private string $name;
28
    private string $supplier;
29
    private Packaging $packaging;
30
    private float $price;
31
    private string $taxes;
32
    private float $quantity;
33
    private float $minStock;
34
35
    /**
36
     * @var ZoneStorage[]
37
     */
38
    private array $zoneStorages;
39
    private string $familyLog;
40
    private bool $active;
41
    private string $slug;
42
43
    public function __construct(
44
        ArticleUuid $uuid,
45
        NameField $name,
46
        Supplier $supplier,
47
        Packaging $packaging,
48
        float $price,
49
        Taxes $taxes,
50
        float $minStock,
51
        array $zoneStorages,
52
        FamilyLog $familyLog,
53
        ?float $quantity = 0.000,
54
        ?bool $active = true
55
    ) {
56
        $this->uuid = $uuid->toString();
57
        $this->name = $name->getValue();
58
        $this->supplier = $supplier->companyName();
59
        $this->packaging = $packaging;
60
        $this->price = $price;
61
        $this->taxes = $taxes->name();
62
        $this->quantity = $quantity ?? 0.000;
63
        $this->minStock = $minStock;
64
        $this->zoneStorages = $zoneStorages;
65
        $this->familyLog = $familyLog->path();
66
        $this->active = $active ?? true;
67
        $this->slug = $name->slugify();
68
    }
69
70
    /**
71
     * @param ZoneStorage[] $zoneStorages
72
     */
73
    public static function create(
74
        ArticleUuid $uuid,
75
        NameField $name,
76
        Supplier $supplier,
77
        Packaging $packaging,
78
        float $price,
79
        Taxes $taxes,
80
        float $minStock,
81
        array $zoneStorages,
82
        FamilyLog $familyLog
83
    ): self {
84
        return new self(
85
            $uuid,
86
            $name,
87
            $supplier,
88
            $packaging,
89
            $price,
90
            $taxes,
91
            $minStock,
92
            $zoneStorages,
93
            $familyLog
94
        );
95
    }
96
97
    public function uuid(): string
98
    {
99
        return $this->uuid;
100
    }
101
102
    public function name(): string
103
    {
104
        return $this->name;
105
    }
106
107
    public function supplier(): string
108
    {
109
        return $this->supplier;
110
    }
111
112
    public function packaging(): Packaging
113
    {
114
        return $this->packaging;
115
    }
116
117
    public function price(): float
118
    {
119
        return $this->price;
120
    }
121
122
    public function taxes(): string
123
    {
124
        return $this->taxes;
125
    }
126
127
    public function quantity(): float
128
    {
129
        return $this->quantity;
130
    }
131
132
    public function minStock(): float
133
    {
134
        return $this->minStock;
135
    }
136
137
    /**
138
     * @return ZoneStorage[]
139
     */
140
    public function zoneStorages(): array
141
    {
142
        return $this->zoneStorages;
143
    }
144
145
    public function familyLog(): string
146
    {
147
        return $this->familyLog;
148
    }
149
150
    public function isActive(): bool
151
    {
152
        return $this->active;
153
    }
154
155
    public function slug(): string
156
    {
157
        return $this->slug;
158
    }
159
160
    public function renameArticle(NameField $name): void
161
    {
162
        $this->name = $name->getValue();
163
        $this->slug = $name->slugify();
164
    }
165
}
166