Media::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 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.io and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusVueStorefrontPlugin\Document\Product\MediaGallery;
14
15
class Media implements \JsonSerializable
16
{
17
    private const IMAGE_PATH = 'image';
18
19
    private const POSITION = 'pos';
20
21
    private const TYPE = 'typ';
22
23
    //    TODO MEDIA -> VID, LAB? image_path & id are only fields in integration boilerplate
24
    private const VID = 'vid';
25
26
    private const LAB = 'lab';
27
28
    private const ID = 'id';
29
30
    /** @var string */
31
    private $imagePath;
32
33
    /** @var int */
34
    private $position;
35
36
    /** @var string */
37
    private $type;
38
39
    /** @var mixed|null */
40
    private $vid = false;
41
42
    /** @var string */
43
    private $lab = '';
44
45
    /** @var int */
46
    private $id;
47
48
    public function __construct(string $imagePath, int $position, ?string $type, int $id)
49
    {
50
        $this->imagePath = $imagePath;
51
        $this->position = $position;
52
        $this->type = $type;
53
        $this->id = $id;
54
    }
55
56
    public function jsonSerialize(): array
57
    {
58
        return [
59
            self::IMAGE_PATH => $this->imagePath,
60
            self::POSITION => $this->position,
61
            self::TYPE => $this->type,
62
            self::VID => $this->vid,
63
            self::LAB => $this->lab,
64
            self::ID => $this->id,
65
        ];
66
    }
67
}
68