Passed
Pull Request — master (#12)
by Laurens
01:19
created

Seats   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 10
dl 0
loc 33
rs 10
c 2
b 1
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getValue() 0 9 2
A addSeat() 0 3 1
A getKey() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\ApplePassbook\MetaData\SemanticTag;
6
7
use LauLamanApps\ApplePassbook\MetaData\SemanticTag;
8
9
class Seats implements SemanticTag
10
{
11
    /** @var Seat[]  */
12
    private array $seats = [];
13
14
    public function __construct(Seat $seat = null)
15
    {
16
        if (isset($seat)){
17
            $this->addSeat($seat);
18
        }
19
    }
20
21
    public function addSeat(Seat $seat): void
22
    {
23
        $this->seats[] = $seat;
24
    }
25
26
    public function getKey(): string
27
    {
28
        return 'seats';
29
    }
30
    /**
31
     * @return array<array<string, string>>
32
     */
33
    public function getValue(): array
34
    {
35
        $seats = [];
36
37
        foreach ($this->seats as $seat) {
38
            $seats[] = $seat->getValue();
39
        }
40
41
        return $seats;
42
    }
43
}