Completed
Pull Request — master (#51)
by Konrad
04:40 queued 01:15
created

Item::slug()   A

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
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO;
14
15
final class Item
16
{
17
    /** @var string */
18
    private $taxonName;
19
20
    /** @var string */
21
    private $name;
22
23
    /** @var string */
24
    private $description;
25
26
    /** @var string */
27
    private $slug;
28
29
    /** @var string */
30
    private $price;
31
32
    /** @var string */
33
    private $image;
34
35
    public function __construct(
36
        string $taxonName,
37
        string $name,
38
        ?string $description,
39
        string $slug,
40
        string $price,
41
        ?string $image
42
    ) {
43
        $this->taxonName = $taxonName;
44
        $this->name = $name;
45
        $this->description = $description;
46
        $this->slug = $slug;
47
        $this->price = $price;
48
        $this->image = $image;
49
    }
50
51
    public function taxonName(): string
52
    {
53
        return $this->taxonName;
54
    }
55
56
    public function name(): string
57
    {
58
        return $this->name;
59
    }
60
61
    public function description(): ?string
62
    {
63
        return $this->description;
64
    }
65
66
    public function slug(): string
67
    {
68
        return $this->slug;
69
    }
70
71
    public function price(): string
72
    {
73
        return $this->price;
74
    }
75
76
    public function image(): ?string
77
    {
78
        return $this->image;
79
    }
80
81
    public function toArray(): array
82
    {
83
        return [
84
            'taxon_name' => $this->taxonName(),
85
            'name' => $this->name(),
86
            'description' => $this->description() ?: '',
87
            'slug' => $this->slug(),
88
            'price' => $this->price(),
89
            'image' => $this->image() ?: '',
90
        ];
91
    }
92
}
93