Completed
Push — master ( fa2f9e...da6516 )
by Gabriel
02:23
created

Product::getImages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Waredesk\Models;
4
5
use DateTime;
6
use Waredesk\Collections\Products\Variants;
7
use JsonSerializable;
8
use Waredesk\Image;
9
10
class Product implements JsonSerializable
11
{
12
    private $id;
13
    private $images;
14
    private $variants;
15
    private $name;
16
    private $description;
17
    private $notes;
18
    private $creation_datetime;
19
    private $modification_datetime;
20
21
    /**
22
     * @var Image
23
     */
24
    private $pendingImage;
25
26 2
    public function __construct()
27
    {
28 2
        $this->variants = new Variants();
29 2
    }
30
31 1
    public function getId(): ?int
32
    {
33 1
        return $this->id;
34
    }
35
36 2
    public function setId(int $id = null)
37
    {
38 2
        $this->id = $id;
39 2
    }
40
41 1
    public function getImages(): ?array
42
    {
43 1
        return $this->images;
44
    }
45
46 2
    public function setImages(array $images = null)
47
    {
48 2
        $this->pendingImage = null;
49 2
        $this->images = $images;
50 2
    }
51
52 1
    public function setImage(Image $image = null)
53
    {
54 1
        $this->pendingImage = $image;
55 1
    }
56
57 2
    public function getVariants(): ?Variants
58
    {
59 2
        return $this->variants;
60
    }
61
62 2
    public function setVariants(Variants $variants)
63
    {
64 2
        $this->variants = $variants;
65 2
    }
66
67 2
    public function getName(): ?string
68
    {
69 2
        return $this->name;
70
    }
71
72 2
    public function setName(string $name = null)
73
    {
74 2
        $this->name = $name;
75 2
    }
76
77 2
    public function getDescription(): ?string
78
    {
79 2
        return $this->description;
80
    }
81
82 2
    public function setDescription(string $description = null)
83
    {
84 2
        $this->description = $description;
85 2
    }
86
87 2
    public function getNotes(): ?string
88
    {
89 2
        return $this->notes;
90
    }
91
92 2
    public function setNotes(string $notes = null)
93
    {
94 2
        $this->notes = $notes;
95 2
    }
96
97
    public function getCreationDatetime(): ?DateTime
98
    {
99
        return $this->creation_datetime;
100
    }
101
102 2
    public function setCreationDatetime(DateTime $creation_datetime = null)
103
    {
104 2
        $this->creation_datetime = $creation_datetime;
105 2
    }
106
107
    public function getModificationDatetime(): ?DateTime
108
    {
109
        return $this->modification_datetime;
110
    }
111
112 2
    public function setModificationDatetime(DateTime $modification_datetime = null)
113
    {
114 2
        $this->modification_datetime = $modification_datetime;
115 2
    }
116
117 2
    public function jsonSerialize()
118
    {
119
        $returnValue = [
120 2
            'variants' => $this->getVariants()->jsonSerialize(),
121 2
            'name' => $this->getName(),
0 ignored issues
show
Bug introduced by
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
122 2
            'description' => $this->getDescription(),
123 2
            'notes' => $this->getNotes(),
124
        ];
125 2
        if ($this->pendingImage) {
126 1
            $returnValue['image'] = $this->pendingImage->toBase64();
127
        }
128 2
        return $returnValue;
129
    }
130
}
131