Passed
Push — master ( 956624...05ed8c )
by Bertrand
08:49
created

CharacteristicDto   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A jsonSerialize() 0 3 1
A type() 0 3 1
A toArray() 0 7 1
1
<?php
2
3
4
namespace App\Src\UseCases\Domain\Context\Dto;
5
6
7
class CharacteristicDto implements \JsonSerializable
8
{
9
    public $uuid;
10
    public $label;
11
    public $prettyLabel;
12
    public $type;
13
    public $icon;
14
    public $opt;
15
16
    public function __construct(string $uuid,  string $label, string $type, ?string $icon, $prettyLabel, array $opt = [])
17
    {
18
        $this->uuid = $uuid;
19
        $this->label = $label;
20
        $this->type = $type;
21
        $this->icon = $icon;
22
        $this->prettyLabel = str_replace('Catégorie:', '', $prettyLabel);
23
        $this->opt = $opt;
24
    }
25
26
    public function type():string
27
    {
28
        return $this->type;
29
    }
30
31
    public function jsonSerialize()
32
    {
33
        return $this->toArray();
34
    }
35
36
    public function toArray()
37
    {
38
        return [
39
            'page' => $this->label,
40
            'icon' => $this->icon,
41
            'caption' => $this->prettyLabel,
42
            'opt' => $this->opt
43
        ];
44
    }
45
}
46