Completed
Push — master ( 7671f5...371846 )
by Romain
32s queued 12s
created

ProductElement   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 4 1
A toArray() 0 8 1
A jsonSerialize() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Message\Attachment\Template\Element;
6
7
class ProductElement implements \JsonSerializable
8
{
9
    /**
10
     * @var string
11
     */
12
    private $id;
13
14
    public function __construct(string $id)
15
    {
16
        $this->id = $id;
17
    }
18
19
    public static function create(string $id): self
20
    {
21
        return new self($id);
22
    }
23
24
    public function toArray(): array
25
    {
26
        $array = [
27
            'id' => $this->id,
28
        ];
29
30
        return array_filter($array);
31
    }
32
33
    public function jsonSerialize(): array
34
    {
35
        return $this->toArray();
36
    }
37
}
38