Completed
Pull Request — master (#342)
by Luc
04:37
created

BookingInfo::sameAs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * @file
5
 * Contains CultuurNet\UDB3\BookingInfo.
6
 */
7
8
namespace CultuurNet\UDB3;
9
10
/**
11
 * BookingInfo info.
12
 */
13
class BookingInfo implements JsonLdSerializableInterface
14
{
15
16
    /**
17
     * @var string
18
     */
19
    protected $price = '';
20
21
    /**
22
     * @var string
23
     */
24
    protected $currency = 'EUR';
25
26
    /**
27
     * @var string
28
     */
29
    protected $phone = '';
30
31
    /**
32
     * @var string
33
     */
34
    protected $email = '';
35
36
    /**
37
     * @var string
38
     */
39
    protected $url = '';
40
41
    /**
42
     * @var string
43
     */
44
    protected $urlLabel = '';
45
46
    /**
47
     * @var string
48
     */
49
    protected $availabilityStarts = '';
50
51
    /**
52
     * @var string
53
     */
54
    protected $availabilityEnds = '';
55
56
    /**
57
     * @var string
58
     */
59
    protected $name = '';
60
61
    /**
62
     * @var string
63
     */
64
    protected $description = '';
65
66
    /**
67
     * @param string $url
68
     * @param string $urlLabel
69
     * @param string $phone
70
     * @param string $email
71
     * @param string $availabilityStarts
72
     * @param string $availabilityEnds
73
     * @param string $name
74
     * @param string $description
75
     */
76
    public function __construct(
77
        $url = '',
78
        $urlLabel = '',
79
        $phone = '',
80
        $email = '',
81
        $availabilityStarts = '',
82
        $availabilityEnds = '',
83
        $name = '',
84
        $description = ''
85
    ) {
86
        $this->url = $url;
87
        $this->urlLabel = $urlLabel;
88
        $this->phone = $phone;
89
        $this->email = $email;
90
        $this->availabilityStarts = $availabilityStarts;
91
        $this->availabilityEnds = $availabilityEnds;
92
        $this->name = $name;
93
        $this->description = $description;
94
    }
95
96
    public function getPhone()
97
    {
98
        return $this->phone;
99
    }
100
101
    public function getEmail()
102
    {
103
        return $this->email;
104
    }
105
106
    public function getUrl()
107
    {
108
        return $this->url;
109
    }
110
111
    public function getUrlLabel()
112
    {
113
        return $this->urlLabel;
114
    }
115
116
    public function getName()
117
    {
118
        return $this->name;
119
    }
120
121
    public function getDescription()
122
    {
123
        return $this->description;
124
    }
125
126
    public function getAvailabilityStarts()
127
    {
128
        return $this->availabilityStarts;
129
    }
130
131
    public function getAvailabilityEnds()
132
    {
133
        return $this->availabilityEnds;
134
    }
135
136
    /**
137
     * {@inheritdoc}
138
     */
139
    public function serialize()
140
    {
141
        return [
142
          'phone' => $this->phone,
143
          'email' => $this->email,
144
          'url' => $this->url,
145
          'urlLabel' => $this->urlLabel,
146
          'name' => $this->name,
147
          'description' => $this->description,
148
          'availabilityStarts' => $this->availabilityStarts,
149
          'availabilityEnds' => $this->availabilityEnds,
150
        ];
151
    }
152
153
    /**
154
     * {@inheritdoc}
155
     */
156
    public static function deserialize(array $data)
157
    {
158
        return new static(
159
            $data['url'], $data['urlLabel'], $data['phone'], $data['email'],
160
            $data['availabilityStarts'], $data['availabilityEnds'], $data['name'], $data['description']
161
        );
162
    }
163
164
    /**
165
     * {@inheritdoc}
166
     */
167
    public function toJsonLd()
168
    {
169
        return $this->serialize();
170
    }
171
172
    /**
173
     * @param BookingInfo $otherBookingInfo
174
     * @return bool
175
     */
176
    public function sameAs(BookingInfo $otherBookingInfo)
177
    {
178
        return $this->toJsonLd() === $otherBookingInfo->toJsonLd();
179
    }
180
}
181