Completed
Push — main ( fffb13...d8afdd )
by Laurent
139:07 queued 124:29
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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 28 1
A create() 0 30 1
A renameSupplier() 0 5 1
A name() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Domain\Model\Supplier;
6
7
use Domain\Model\Common\Entities\FamilyLog;
8
use Domain\Model\Common\VO\ContactAddress;
9
use Domain\Model\Common\VO\EmailField;
10
use Domain\Model\Common\VO\NameField;
11
use Domain\Model\Common\VO\PhoneField;
12
use Domain\Model\Contact;
13
14
class Supplier extends Contact
15
{
16
    /**
17
     * @var int Id of Supplier
18
     */
19
    private $supplierId;
20
21
    /**
22
     * @var string Logistics family
23
     */
24
    private $familyLog;
25
26
    /**
27
     * @var int Delivery delay
28
     */
29
    private $delayDeliv;
30
31
    /**
32
     * @var array Order days table
33
     */
34
    private $orderDays;
35
36
    /**
37
     * @var bool Active/Inactive
38
     */
39
    private $active;
40
41
    /**
42
     * @var string
43
     */
44
    private $slug;
45
46
    /**
47
     * Supplier constructor.
48
     *
49
     * @param NameField      $name
50
     * @param ContactAddress $address
51
     * @param PhoneField     $phone
52
     * @param PhoneField     $facsimile
53
     * @param EmailField     $email
54
     * @param string         $contact
55
     * @param PhoneField     $cellphone
56
     * @param FamilyLog      $familyLog
57
     * @param int            $delayDeliv
58
     * @param array          $orderDays
59
     * @param bool           $active
60
     */
61
    public function __construct(
62
        NameField $name,
63
        ContactAddress $address,
64
        PhoneField $phone,
65
        PhoneField $facsimile,
66
        EmailField $email,
67
        string $contact,
68
        PhoneField $cellphone,
69
        FamilyLog $familyLog,
70
        int $delayDeliv,
71
        array $orderDays,
72
        bool $active = true
73
    ) {
74
        parent::__construct(
75
            $name,
76
            $address,
77
            $phone->getValue(),
78
            $facsimile->getValue(),
79
            $email,
80
            $contact,
81
            $cellphone->getValue()
82
        );
83
        $this->familyLog = $familyLog->path();
84
        $this->delayDeliv = $delayDeliv;
85
        $this->orderDays = $orderDays;
86
        $this->slug = $name->slugify();
87
        $this->active = $active;
88
    }
89
90
    public static function create(
91
        NameField $name,
92
        string $address,
93
        string $zipCode,
94
        string $town,
95
        string $country,
96
        PhoneField $phone,
97
        PhoneField $facsimile,
98
        EmailField $email,
99
        string $contact,
100
        PhoneField $gsm,
101
        FamilyLog $familyLog,
102
        int $delayDeliv,
103
        array $orderDays,
104
        bool $active = true
105
    ): self {
106
        return new self(
107
            $name,
108
            ContactAddress::fromString($address, $zipCode, $town, $country),
109
            $phone,
110
            $facsimile,
111
            $email,
112
            $contact,
113
            $gsm,
114
            $familyLog,
115
            $delayDeliv,
116
            $orderDays,
117
            $active
118
        );
119
    }
120
121
    final public function renameSupplier(NameField $name): void
122
    {
123
        $this->name = $name->getValue();
124
        $this->slug = $name->slugify();
125
    }
126
127
    final public function name(): string
128
    {
129
        return $this->name;
130
    }
131
}
132