Child   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 54
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A jsonSerialize() 0 11 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\Product\ConfigurableChildren;
14
15
use BitBag\SyliusVueStorefrontPlugin\Document\Product\Price;
16
17
class Child implements \JsonSerializable
18
{
19
    private const PRICE = 'price';
20
21
    private const NAME = 'name';
22
23
    private const SKU = 'sku';
24
25
    private const CUSTOM_ATTRIBUTES = 'custom_attributes';
26
27
    //    TODO FIELDS INSIDE CHILD IN DEMO APP ONLY below, IN DOCS '$price' is not whole Price class
28
    //     + categoryIds[] + options[] + product_options[] -custom_attributes[]
29
30
    //    private const DEMO_APP = [
31
    //        Details::IMAGE, Details::THUMBNAIL, Details::COLOR, Details::SMALL_IMAGE, Details::TAX_CLASS_ID,
32
    //        Details::HAS_OPTIONS, Details::URL_KEY, Details::SIZE, Details::NAME, Details::STATUS,
33
    //    ];
34
35
    /** @var Price */
36
    private $price;
37
38
    /** @var string */
39
    private $name;
40
41
    /** @var string */
42
    private $sku;
43
44
    /** @var array */
45
    private $customAttributes;
46
47
    public function __construct(
48
        Price $price,
49
        string $name,
50
        string $sku,
51
        array $customAttributes
52
    ) {
53
        $this->price = $price;
54
        $this->name = $name;
55
        $this->sku = $sku;
56
        $this->customAttributes = $customAttributes;
57
    }
58
59
    public function jsonSerialize(): array
60
    {
61
        return \array_merge(
62
            $this->price->toArray(),
63
            [
64
                self::NAME => $this->name,
65
                self::SKU => $this->sku,
66
            ],
67
            $this->customAttributes
68
        );
69
    }
70
}
71