Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
82.11% covered (warning)
82.11%
78 / 95
94.29% covered (success)
94.29%
33 / 35
CRAP
0.00% covered (danger)
0.00%
0 / 1
Session
82.11% covered (warning)
82.11%
78 / 95
94.29% covered (success)
94.29%
33 / 35
98.08
0.00% covered (danger)
0.00%
0 / 1
 getDefaults
100.00% covered (success)
100.00%
34 / 34
100.00% covered (success)
100.00%
1 / 1
1
 getContent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getBasket
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHuman
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRequests
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getProviders
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getProcess
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSource
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getScope
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAuthKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLastStep
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
 getStatus
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 removeLastStep
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getSelectedDate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getEntryData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isEmpty
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
4
 isInChange
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 isStalled
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 isReserved
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 isConfirmed
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 isPreconfirmed
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
 isFinished
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 isProcessDeleted
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasStatus
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasProcess
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasAuthKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasChangedProcess
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasPreviousAppointmentSearch
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasConfirmationNotification
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasRequests
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasProvider
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasScope
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasDate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasDifferentEntry
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
8
 withOidcDataOnly
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
72
1<?php
2
3namespace BO\Zmsentities;
4
5/**
6 * Extension for Twig and Slim
7 *
8 * @SuppressWarnings(PublicMethod)
9 * @SuppressWarnings(TooManyMethods)
10 * @SuppressWarnings(Complexity)
11 */
12class Session extends Schema\Entity
13{
14    const PRIMARY = 'id';
15
16    public static $schema = "session.json";
17
18    public function getDefaults()
19    {
20        return [
21            'content' => array(
22                'basket' => [
23                    'requests' => '',
24                    'providers' => '',
25                    'scope' => 0,
26                    'process' => 0,
27                    'date' => 0,
28                    'familyName' => '',
29                    'email' => '',
30                    'telehone' => '',
31                    'amendment' => '',
32                    'authKey' => ''
33                ],
34                'human' => [
35                    'captcha_text' => '',
36                    'client' => 0,
37                    'ts' => 0,
38                    'origin' => '',
39                    'remoteAddress' => '',
40                    'referer' => '',
41                    'step' => array(
42                      'dayselect' => 0,
43                      'timeselect' => 0,
44                      'register' => 0,
45                      'summary' => 0
46                    )
47                ],
48                'source' => 'dldb',
49                'status' => 'start',
50                'X-Authkey' => '',
51                'error' => ''
52            )
53        ];
54    }
55
56    public function getContent()
57    {
58        return $this->toProperty()->content->get();
59    }
60
61    public function getBasket()
62    {
63        return $this->toProperty()->content->basket->get();
64    }
65
66    public function getHuman()
67    {
68        return $this->toProperty()->content->human->get();
69    }
70
71    public function getRequests()
72    {
73        return Helper\Sorter::toSortedCsv($this->toProperty()->content->basket->requests->get());
74    }
75
76    public function getProviders()
77    {
78        return Helper\Sorter::toSortedCsv($this->toProperty()->content->basket->providers->get());
79    }
80
81    public function getProcess()
82    {
83        return $this->toProperty()->content->basket->process->get();
84    }
85
86    public function getSource()
87    {
88        return $this->toProperty()->content->source->get();
89    }
90
91    public function getScope()
92    {
93        return $this->toProperty()->content->basket->scope->get();
94    }
95
96    public function getAuthKey()
97    {
98        return $this->toProperty()->content->basket->authKey->get();
99    }
100
101    public function getLastStep()
102    {
103        $steps = $this->toProperty()->content->human->step->get();
104        $steps = (is_array($steps)) ? array_keys($steps) : null;
105        return (null !== $steps) ? end($steps) : $steps;
106    }
107
108    public function getStatus()
109    {
110        return $this->toProperty()->content->status->get();
111    }
112
113    public function removeLastStep()
114    {
115        unset($this->content['human']['step'][$this->getLastStep()]);
116        return $this;
117    }
118
119    /**
120     *
121     * Get selected date
122     *
123     * @return integer
124     */
125    public function getSelectedDate()
126    {
127        return $this->toProperty()->content->basket->date->get();
128    }
129
130    /**
131     *
132     * Get entry data
133     *
134     * @return array
135     */
136    public function getEntryData()
137    {
138        return $this->toProperty()->content->entry->get();
139    }
140
141    public function isEmpty()
142    {
143        return (! $this->hasProvider() && ! $this->hasRequests() && ! $this->hasScope()) ? true : false;
144    }
145
146    public function isInChange()
147    {
148        return ('inChange' == $this->getStatus()) ? true : false;
149    }
150
151    public function isStalled()
152    {
153        return ('stalled' == $this->getStatus()) ? true : false;
154    }
155
156    public function isReserved()
157    {
158        return ('reserved' == $this->getStatus()) ? true : false;
159    }
160
161    public function isConfirmed()
162    {
163        return ('confirmed' == $this->getStatus()) ? true : false;
164    }
165
166    public function isPreconfirmed()
167    {
168        return ('preconfirmed' == $this->getStatus()) ? true : false;
169    }
170
171    public function isFinished()
172    {
173        return ('finished' == $this->getStatus()) ? true : false;
174    }
175
176    public function isProcessDeleted()
177    {
178        return ! $this->hasProcess();
179    }
180
181    public function hasStatus()
182    {
183        return (null === $this->getStatus()) ? false : true;
184    }
185
186    public function hasProcess()
187    {
188        return (null === $this->getProcess()) ? false : true;
189    }
190
191    public function hasAuthKey()
192    {
193        return (null === $this->getAuthKey()) ? false : true;
194    }
195
196    public function hasChangedProcess()
197    {
198        return ('inChange' == $this->getStatus()) ? true : false;
199    }
200
201    public function hasPreviousAppointmentSearch()
202    {
203        return ('inProgress' == $this->getStatus()) ? true : false;
204    }
205
206    public function hasConfirmationNotification()
207    {
208        return ($this->toProperty()->content->confirmationNotification->get()) ? true : false;
209    }
210
211    /**
212     * Check if requests exists
213     *
214     * @return boolean
215     */
216    public function hasRequests()
217    {
218        return ($this->getRequests()) ? true : false;
219    }
220
221    /**
222     *
223     * Check if provider exists
224     *
225     * @return boolean
226     */
227    public function hasProvider()
228    {
229        return ($this->getProviders()) ? true : false;
230    }
231
232    /**
233     *
234     * Check if scope exists
235     *
236     * @return boolean
237     */
238    public function hasScope()
239    {
240        return ($this->getScope()) ? true : false;
241    }
242
243    /**
244     *
245     * Check if date exists
246     *
247     * @return boolean
248     */
249    public function hasDate()
250    {
251        return ($this->getSelectedDate()) ? true : false;
252    }
253
254    /**
255     *
256     * Check if entry parameter are different
257     *
258     * @return boolean
259     */
260    public function hasDifferentEntry($newEntryData)
261    {
262        return (
263            ($this->getProviders() || $this->getScope()) &&
264            $this->getRequests() &&
265            $this->getEntryData() &&
266            (
267                !($this->getProviders() == Helper\Sorter::toSortedCsv($newEntryData['providers'])) ||
268                !($this->getRequests() == Helper\Sorter::toSortedCsv($newEntryData['requests'])) ||
269                !($this->getScope() == $newEntryData['scope'])
270            )
271         ) ? true : false;
272    }
273
274    public function withOidcDataOnly()
275    {
276        $entity = clone $this;
277        if ($entity->toProperty()->content->basket->isAvailable()) {
278            unset($entity->content['basket']);
279        }
280        if ($entity->toProperty()->content->human->isAvailable()) {
281            unset($entity->content['human']);
282        }
283        if ($entity->toProperty()->content->entry->isAvailable()) {
284            unset($entity->content['entry']);
285        }
286        if ($entity->toProperty()->content->source->isAvailable()) {
287            unset($entity->content['source']);
288        }
289        if ($entity->toProperty()->content->status->isAvailable()) {
290            unset($entity->content['status']);
291        }
292        if ($entity->toProperty()->content['X-Authkey']->isAvailable()) {
293            unset($entity->content['X-Authkey']);
294        }
295        if ($entity->toProperty()->content->error->isAvailable()) {
296            unset($entity->content['error']);
297        }
298        return $entity;
299    }
300}