Category   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 121
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 29 1
A getDocumentId() 0 4 1
A toElasticArray() 0 18 1
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;
14
15
class Category implements Indexable
16
{
17
    private const ENTITY_ID = 'id';
18
19
    private const PARENT_ID = 'parent_id';
20
21
    private const NAME = 'name';
22
23
    private const IS_ACTIVE = 'is_active';
24
25
    private const POSITION = 'position';
26
27
    private const LEVEL = 'level';
28
29
    private const PRODUCT_COUNT = 'product_count';
30
31
    private const CHILDREN_DATA = 'children_data';
32
33
    private const PATH = 'path';
34
35
    private const CHILDREN_COUNT = 'children_count';
36
37
    private const URL_KEY = 'url_key';
38
39
    private const URL_PATH = 'url_path';
40
41
    private const SLUG = 'slug';
42
43
    /** @var int */
44
    private $documentId;
45
46
    /** @var int */
47
    private $entityId;
48
49
    /** @var int|null */
50
    private $parentId;
51
52
    /** @var string */
53
    private $name;
54
55
    /** @var bool */
56
    private $isActive;
57
58
    /** @var int */
59
    private $position;
60
61
    /** @var int */
62
    private $level;
63
64
    /** @var int */
65
    private $productCount;
66
67
    /** @var self[] */
68
    private $childrenData;
69
70
    /** @var string */
71
    private $path;
72
73
    /** @var int */
74
    private $childrenCount;
75
76
    /** @var string */
77
    private $urlKey;
78
79
    /** @var string */
80
    private $urlPath;
81
82
    public function __construct(
83
        int $documentId,
84
        int $entityId,
85
        ?int $parentId,
86
        string $name,
87
        bool $isActive,
88
        int $position,
89
        int $level,
90
        int $productCount,
91
        array $childrenData,
92
        string $path,
93
        int $childrenCount,
94
        string $urlKey,
95
        string $urlPath
96
    ) {
97
        $this->documentId = $documentId;
98
        $this->entityId = $entityId;
99
        $this->parentId = $parentId;
100
        $this->name = $name;
101
        $this->isActive = $isActive;
102
        $this->position = $position;
103
        $this->level = $level;
104
        $this->productCount = $productCount;
105
        $this->childrenData = $childrenData;
106
        $this->path = $path;
107
        $this->childrenCount = $childrenCount;
108
        $this->urlKey = $urlKey;
109
        $this->urlPath = $urlPath;
110
    }
111
112
    public function getDocumentId(): int
113
    {
114
        return $this->documentId;
115
    }
116
117
    public function toElasticArray(): array
118
    {
119
        return [
120
            self::ENTITY_ID => $this->entityId,
121
            self::PARENT_ID => $this->parentId,
122
            self::NAME => $this->name,
123
            self::IS_ACTIVE => $this->isActive,
124
            self::POSITION => $this->position,
125
            self::LEVEL => $this->level,
126
            self::PRODUCT_COUNT => $this->productCount,
127
            self::CHILDREN_DATA => $this->childrenData,
128
            self::PATH => $this->path,
129
            self::CHILDREN_COUNT => (string) $this->childrenCount,
130
            self::URL_KEY => $this->urlKey,
131
            self::URL_PATH => $this->urlPath,
132
            self::SLUG => $this->urlKey,
133
        ];
134
    }
135
}
136