Entity::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
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\Category;
14
15
class Entity implements \JsonSerializable
16
{
17
    private const CATEGORY_ID = 'category_id';
18
19
    private const IS_PARENT = 'is_parent';
20
21
    private const NAME = 'name';
22
23
    private const SLUG = 'slug';
24
25
    private const PATH = 'path';
26
27
    //    TODO CATEGORY IN VS DOCS, BOILERPLATE APP / DEMO APP
28
    private const VS_DOCS = [self::CATEGORY_ID, self::NAME];
29
30
    private const DEMO_APP = [self::PATH, self::CATEGORY_ID, self::NAME, self::SLUG];
31
32
    /** @var int */
33
    private $id;
34
35
    /** @var bool */
36
    private $isParent;
37
38
    /** @var string */
39
    private $name;
40
41
    /** @var string */
42
    private $slug;
43
44
    /** @var string */
45
    private $path;
46
47
    public function __construct(int $id, bool $isParent, string $name, string $slug, string $path)
48
    {
49
        $this->id = $id;
50
        $this->isParent = $isParent;
51
        $this->name = $name;
52
        $this->slug = $slug;
53
        $this->path = $path;
54
    }
55
56
    public function jsonSerialize(): array
57
    {
58
        return [
59
            self::CATEGORY_ID => $this->id,
60
            self::IS_PARENT => $this->isParent,
61
            self::NAME => $this->name,
62
            self::SLUG => $this->slug,
63
            self::PATH => $this->path,
64
        ];
65
    }
66
}
67