Completed
Branch develop (8166a6)
by Romain
01:52
created

AirlineCheckIn   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A jsonSerialize() 0 19 1
1
<?php
2
namespace Kerox\Messenger\Model\Message\Attachment\Template;
3
4
use Kerox\Messenger\Model\Message\Attachment\Template;
5
6
class AirlineCheckIn extends AbstractAirline
7
{
8
9
    /**
10
     * @var string
11
     */
12
    protected $introMessage;
13
14
    /**
15
     * @var string
16
     */
17
    protected $pnrNumber;
18
19
    /**
20
     * @var \Kerox\Messenger\Model\Message\Attachment\Template\Airline\FlightInfo[]
21
     */
22
    protected $flightInfo;
23
24
    /**
25
     * @var string
26
     */
27
    protected $checkinUrl;
28
29
    /**
30
     * AirlineCheckIn constructor.
31
     *
32
     * @param string $introMessage
33
     * @param string $locale
34
     * @param string $pnrNumber
35
     * @param array $flightInfo
36
     * @param string $checkinUrl
37
     */
38
    public function __construct(string $introMessage,
39
                                string $locale,
40
                                string $pnrNumber,
41
                                array $flightInfo,
42
                                string $checkinUrl
43
    ) {
44
        parent::__construct($locale);
45
46
        $this->introMessage = $introMessage;
47
        $this->pnrNumber = $pnrNumber;
48
        $this->flightInfo = $flightInfo;
49
        $this->checkinUrl = $checkinUrl;
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    public function jsonSerialize(): array
56
    {
57
        $payload = [
58
            'template_type' => Template::TYPE_AIRLINE_CHECKIN,
59
            'intro_message' => $this->introMessage,
60
            'locale' => $this->locale,
61
            'theme_color' => $this->themeColor,
62
            'pnr_number' => $this->pnrNumber,
63
            'flight_info' => $this->flightInfo,
64
            'checkin_url' => $this->checkinUrl,
65
        ];
66
67
        $json = parent::jsonSerialize();
68
        $json += [
69
            'payload' => array_filter($payload),
70
        ];
71
72
        return $json;
73
    }
74
}
75