BoardingPass::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Passbook package.
5
 *
6
 * (c) Eymen Gunay <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Passbook\Type;
13
14
use Passbook\Pass;
15
use Passbook\Pass\Structure;
16
17
/**
18
 * BoardingPass
19
 *
20
 * @author Eymen Gunay <[email protected]>
21
 */
22
class BoardingPass extends Pass
23
{
24
    /**
25
     * Pass type
26
     * @var string
27
     */
28
    protected $type = 'boardingPass';
29
30
    /**
31
     * Pass structure
32
     * @var Structure
33
     */
34
    protected $structure;
35
36
    /**
37
     * Type of transit. Must be one of the following values:
38
     * PKTransitTypeAir, PKTransitTypeBoat, PKTransitTypeBus, PKTransitTypeGeneric, PKTransitTypeTrain
39
     * @var string
40
     */
41
    protected $transitType;
42
43
    /**
44
     * @var string
45
     */
46
    public const TYPE_AIR = 'PKTransitTypeAir';
47
48
    /**
49
     * @var string
50
     */
51
    public const TYPE_BOAT = 'PKTransitTypeBoat';
52
53
    /**
54
     * @var string
55
     */
56
    public const TYPE_BUS = 'PKTransitTypeBus';
57
58
    /**
59
     * @var string
60
     */
61
    public const TYPE_GENERIC = 'PKTransitTypeGeneric';
62
63
    /**
64
     * @var string
65
     */
66
    public const TYPE_TRAIN = 'PKTransitTypeTrain';
67
68
    /**
69
     * Class constructor
70
     *
71
     * @param string $serialNumber
72
     * @param string $description
73
     * @param string $transitType
74
     */
75 1
    public function __construct($serialNumber, $description, $transitType = self::TYPE_GENERIC)
76
    {
77
        // Required for boarding passes; otherwise not allowed
78 1
        $this->transitType = $transitType;
79
        // Call parent
80 1
        parent::__construct($serialNumber, $description);
81
    }
82
83 1
    public function toArray()
84
    {
85 1
        $array = parent::toArray();
86 1
        $array[$this->getType()]['transitType'] = $this->transitType;
87
88 1
        return $array;
89
    }
90
}
91