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

ProductElement::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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