Passed
Push — develop ( a6f0fe...5308a3 )
by Daniel
24:47 queued 09:44
created

Bookwhen::setLogging()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen;
6
7
use InShore\Bookwhen\BookwhenApi;
8
use InShore\Bookwhen\Client;
9
use InShore\Bookwhen\Domain\Attachment;
10
use InShore\Bookwhen\Domain\ClassPass;
0 ignored issues
show
Bug introduced by
The type InShore\Bookwhen\Domain\ClassPass was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use InShore\Bookwhen\Domain\Event;
12
use InShore\Bookwhen\Domain\Location;
13
use InShore\Bookwhen\Domain\Ticket;
14
use InShore\Bookwhen\Exceptions\ValidationException;
15
use InShore\Bookwhen\Interfaces\BookwhenInterface;
16
use InShore\Bookwhen\Validator;
17
use Monolog\Level;
18
use Monolog\Logger;
19
use Monolog\Handler\StreamHandler;
20
21
final class Bookwhen implements BookwhenInterface
22
{
23
    private null | Client $client;
24
25
    /**
26
     *
27
     * @var unknown
0 ignored issues
show
Bug introduced by
The type InShore\Bookwhen\unknown was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
     */
29
    public Attachment $attachment;
30
31
    /**
32
     *
33
     * @var unknown
34
     */
35
    public array $attachments = [];
36
37
    /**
38
     *
39
     * @var unknown
40
     */
41
    public ClassPass $classPass;
42
43
    /**
44
     *
45
     * @var unknown
46
     */
47
    public array $classPasses = [];
48
49
    /**
50
     *
51
     * @var unknown
52
     */
53
    public Event $event;
54
55
    /**
56
     *
57
     * @var unknown
58
     */
59
    public array $events = [];
60
61
    /**
62
     *
63
     * @var unknown
64
     */
65
    private array $filters = [];
66
67
    /**
68
     *
69
     */
70
    public readonly Location $location;
71
72
    /**
73
     *
74
     * @var unknown
75
     */
76
    private array $includes = [];
77
    /**
78
79
     */
80
    public Ticket $ticket;
81
82
    /**
83
84
     */
85
    public array $tickets = [];
86
87
    /**
88
        *
89
     */
90
    public $locations = [];
91
92
93
    /** @var string The path to the log file */
94
    private $logFile;
0 ignored issues
show
introduced by
The private property $logFile is not used, and could be removed.
Loading history...
95
96
    /** @var object loging object. */
97
    private $logger;
0 ignored issues
show
introduced by
The private property $logger is not used, and could be removed.
Loading history...
98
99
    /** @var string the logging level. */
100
    private string $logLevel;
0 ignored issues
show
introduced by
The private property $logLevel is not used, and could be removed.
Loading history...
101
102
103
104
    /**
105
     * Creates a new Bookwhen Client with the given API token.
106
     * @todo logging
107
     */
108
    public function __construct(
109
        private $validator = new Validator()
110
    ) {
111
        //         $this->logFile = $logFile;
112
        //         $this->logLevel = $logLevel;
113
        //         $this->logger = new Logger('inShore Bookwhen API');
114
        //         $this->logger->pushHandler(new StreamHandler($this->logFile, $this->logLevel));
115
        $this->client = BookwhenApi::client($_ENV['INSHORE_BOOKWHEN_API_KEY']);
116
    }
117
118
    /**
119
     *
120
     * {@inheritDoc}
121
     * @see \InShore\Bookwhen\Interfaces\ClientInterface::attachment()
122
     * @todo all attachment properties
123
     */
124
    public function attachment(string $attachmentId): Attachment
125
    {
126
        if (!$this->validator->validId($attachmentId, 'attachment')) {
127
            throw new ValidationException('attachmentId', $attachmentId);
128
        }
129
130
        $attachment = $this->client->attachments()->retrieve($attachmentId);
0 ignored issues
show
Bug introduced by
The method attachments() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

130
        $attachment = $this->client->/** @scrutinizer ignore-call */ attachments()->retrieve($attachmentId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
131
132
        return $this->attachment = new Attachment(
0 ignored issues
show
Documentation Bug introduced by
It seems like new InShore\Bookwhen\Dom...id, $attachment->title) of type InShore\Bookwhen\Domain\Attachment is incompatible with the declared type InShore\Bookwhen\unknown of property $attachment.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
Bug introduced by
The call to InShore\Bookwhen\Domain\Attachment::__construct() has too few arguments starting with fileSizeBytes. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

132
        return $this->attachment = /** @scrutinizer ignore-call */ new Attachment(

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
133
            $attachment->id,
134
            $attachment->title,
135
        );
136
    }
137
138
    /**
139
     *
140
     * {@inheritDoc}
141
     * @see \InShore\Bookwhen\Interfaces\BookwhenInterface::attachment()
142
     * @todo
143
     */
144
    public function attachments(
145
        string $title = null,
146
        string $fileName = null,
147
        string $fileType = null
148
    ): array {
149
        //$this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')');
150
151
        if (!is_null($title) && !$this->validator->validTitle($title)) {
152
            throw new ValidationException('title', $title);
153
        }
154
155
        if (!is_null($fileName) && !$this->validator->validFileName($fileName)) {
156
            throw new ValidationException('file name', $fileName);
157
        }
158
159
        if (!is_null($fileType) && !$this->validator->validFileType($fileType)) {
160
            throw new ValidationException('file type', $fileType);
161
        }
162
163
        $attachments = $this->client->attachments()->list();
164
165
        foreach ($attachments->data as $attachment) {
166
            array_push($this->attachment, new Attachment(
0 ignored issues
show
Bug introduced by
$this->attachment of type InShore\Bookwhen\Domain\Attachment is incompatible with the type array expected by parameter $array of array_push(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

166
            array_push(/** @scrutinizer ignore-type */ $this->attachment, new Attachment(
Loading history...
Bug introduced by
The call to InShore\Bookwhen\Domain\Attachment::__construct() has too few arguments starting with fileUrl. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

166
            array_push($this->attachment, /** @scrutinizer ignore-call */ new Attachment(

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
167
                $attachment->id,
168
            ));
169
        }
170
171
        return $this->attachments;
172
    }
173
174
    /**
175
     *
176
     * {@inheritDoc}
177
     * @see \InShore\Bookwhen\Interfaces\ClientInterface::getClassPass()
178
     * @todo
179
     */
180
    public function classPass(string $classPassId): ClassPass
181
    {
182
        //         $this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')');
183
184
        //       if (!$this->validator->validId($classPassId, 'classPass')) {
185
        //           throw new ValidationException('classPassId', $classPassId);
186
        //      }
187
188
        $classPass = $this->client->classPasses()->retrieve($classPassId);
189
190
        return new ClassPass(
191
            $classPass->details,
192
            $classPass->id,
193
            $classPass->number_available,
194
            $classPass->title,
195
            $classPass->usage_allowance,
196
            $classPass->usage_type,
197
            $classPass->use_restricted_for_days
198
        );
199
    }
200
201
    /**
202
     *
203
     * {@inheritDoc}
204
     * @see \InShore\Bookwhen\Interfaces\ClientInterface::getClassPasses()
205
     * @todo break params on to multiplper lines..
206
     */
207
    public function classPasses(
208
        $title = null,
209
        $detail = null,
210
        $usageType = null,
211
        $cost = null,
212
        $usageAllowance = null,
213
        $useRestrictedForDays = null
214
    ): array {
215
216
        //$this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')');
217
218
        if (!is_null($title) && !$this->validator->validTitle($title)) {
219
            throw new ValidationException('title', $title);
220
        }
221
222
        // @todo remaingin validation
223
224
        $classPasses = $this->client->classPasses()->list([]);
0 ignored issues
show
Unused Code introduced by
The call to InShore\Bookwhen\Resources\ClassPasses::list() has too many arguments starting with array(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

224
        $classPasses = $this->client->classPasses()->/** @scrutinizer ignore-call */ list([]);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
225
226
        foreach ($classPasses->data as $classPass) {
227
            array_push($this->classPasses, new classPasses(
0 ignored issues
show
Bug introduced by
The type InShore\Bookwhen\classPasses was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
228
                $ticket->details,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ticket seems to be never defined.
Loading history...
229
                $ticket->id,
230
                $ticket->title
231
            ));
232
        }
233
        return $this->classPasses;
234
    }
235
236
    /**
237
     *
238
     * {@inheritDoc}
239
     * @see \InShore\Bookwhen\Interfaces\BookwhenInterface::event()
240
     * @todo filters.
241
     */
242
    public function event(
243
        string $eventId,
244
        bool $attachments = false,
245
        bool $location = false,
246
        bool $tickets = false,
247
        bool $ticketsClassPasses = false,
248
        bool $ticketsEventslocation = false
249
    ): Event {
250
        //$this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')');
251
252
        if (!$this->validator->validId($eventId, 'event')) {
253
            throw new ValidationException('eventId', $eventId);
254
        }
255
256
        $event = $this->client->events()->retrieve($eventId);
257
258
        $eventAttachments = [];
259
        $eventTickets = [];
260
261
        // attachments
262
        if($attachments) {
263
            foreach ($event->attachments as $eventAttachment) {
264
                $attachment = $this->client->attachments()->retrieve($eventAttachment['id']);
265
                array_push($eventAttachments, new Attachment(
0 ignored issues
show
Bug introduced by
The call to InShore\Bookwhen\Domain\Attachment::__construct() has too few arguments starting with fileSizeBytes. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

265
                array_push($eventAttachments, /** @scrutinizer ignore-call */ new Attachment(

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
266
                    $attachment->id,
267
                    $attachment->title,
268
                ));
269
            }
270
        }
271
272
        // location
273
        // @todo resolve dynamic type
274
        if(!$location) {
275
            $eventLocation = new Location(
276
                null,
277
                null,
278
                $event->locationId
279
            );
280
        } else {
281
            $location = $this->client->locations()->retrieve($event->locationId);
282
            $eventLocation = new Location(
283
                $location->addressText,
284
                $location->additionalInfo,
285
                $location->id,
286
                $location->latitude,
287
                $location->longitude,
288
                $location->mapUrl,
289
                $location->zoom
290
            );
291
        }
292
293
        // tickets
294
        if($tickets) {
295
            foreach ($event->tickets as $eventTicket) {
296
                $ticket = $this->client->tickets()->retrieve($eventTicket['id']);
297
                array_push($eventTickets, new Ticket(
298
                    $ticket->available,
299
                    $ticket->availableFrom,
300
                    $ticket->availableTo,
301
                    $ticket->builtBasketUrl,
302
                    $ticket->builtBasketIframeUrl,
303
                    $ticket->courseTicket,
304
                    $ticket->details,
305
                    $ticket->groupTicket,
306
                    $ticket->groupMin,
307
                    $ticket->groupMax,
308
                    $ticket->id,
309
                    $ticket->numberIssued,
310
                    $ticket->numberTaken,
311
                    $ticket->title
312
                ));
313
            }
314
        }
315
316
        // ticketsClassPasses
317
        // @todo
318
319
        // ticketsEvents
320
        // @todo
321
322
        return $this->event = new Event(
0 ignored issues
show
Documentation Bug introduced by
It seems like new InShore\Bookwhen\Dom...e, $event->waitingList) of type InShore\Bookwhen\Domain\Event is incompatible with the declared type InShore\Bookwhen\unknown of property $event.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
323
            $event->allDay,
324
            $eventAttachments,
325
            $event->attendeeCount,
326
            $event->attendeeLimit,
327
            $event->details,
328
            $event->endAt,
329
            $event->id,
330
            $eventLocation,
331
            $event->maxTicketsPerBooking,
332
            $event->startAt,
333
            $eventTickets,
334
            $event->title,
335
            $event->waitingList
336
        );
337
    }
338
339
    /**
340
     *
341
     * {@inheritDoc}
342
     * @see \InShore\Bookwhen\Interfaces\ClientInterface::getEvents()
343
     */
344
    public function Events(
345
        $calendar = false,
346
        $entry = false,
347
        $location = [],
348
        $tags = [],
349
        $title = [],
350
        $detail = [],
351
        $from = null,
352
        $to = null,
353
        $includeAttachments = false,
354
        $includeLocation = false,
355
        $includeTickets = false,
356
        $includeTicketsClassPasses = false,
357
        $includeTicketsEvents = false
358
    ): array {
359
360
        //$this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')');
361
362
        // Validate $calendar
363
        // @todo details required
364
365
        // Validate $detail
366
        if (!empty($detail)) {
367
            if (!is_array($detail)) {
368
                throw new ValidationException('detail', implode(' ', $detail));
369
            } else {
370
                $detail = array_unique($detail);
371
                foreach($detail as $item) {
372
                    if (!$this->validator->validLocation($item)) {
373
                        throw new ValidationException('detail', $item);
374
                    }
375
                }
376
                $this->filters['filter[detail]'] = implode(',', $detail);
377
            }
378
        }
379
380
        // Validate $entry
381
        // @todo details required
382
383
        // Validate $from;
384
        if (!empty($from)) {
385
            if (!$this->validator->validFrom($from, $to)) {
386
                throw new ValidationException('from', $from . '-' . $to);
387
            } else {
388
                $this->filters['filter[from]'] = $from;
389
            }
390
        }
391
392
        // Validate $location
393
        if (!empty($location)) {
394
            if (!is_array($location)) {
395
                throw new ValidationException('location', implode(' ', $title));
396
            } else {
397
                $location = array_unique($location);
398
                foreach($location as $item) {
399
                    if (!$this->validator->validLocation($item)) {
400
                        throw new ValidationException('location', $item);
401
                    }
402
                }
403
                $this->filters['filter[location]'] = implode(',', $location);
404
            }
405
        }
406
407
        // Validate $tags.
408
        if (!empty($tags)) {
409
            if (!is_array($tags)) {
410
                throw new ValidationException('tags', implode(' ', $tags));
411
            } else {
412
                $tags = array_unique($tags);
413
                foreach ($tags as $tag) {
414
                    if (!empty($tag) && !$this->validator->validTag($tag)) {
415
                        throw new ValidationException('tag', $tag);
416
                    }
417
                }
418
            }
419
            $this->filters['filter[tag]'] = implode(',', $tags);
420
        }
421
422
        // Validate $title;
423
        if (!empty($title)) {
424
            if (!is_array($title)) {
425
                throw new ValidationException('title', implode(' ', $title));
426
            } else {
427
                $title = array_unique($title);
428
                foreach($title as $item) {
429
                    if (!$this->validator->validTitle($item)) {
430
                        throw new ValidationException('title', $item);
431
                    }
432
                }
433
                $this->filters['filter[title]'] = implode(',', $title);
434
            }
435
        }
436
437
        // Validate $to;
438
        if (!empty($to)) {
439
            if (!$this->validator->validTo($to, $from)) {
440
                throw new ValidationException('to', $to . '-' . $from);
441
            } else {
442
                $this->filters['filter[to]'] = $to;
443
            }
444
        }
445
446
        // Validate $includeAttachments;
447
        if (!$this->validator->validInclude($includeAttachments)) {
448
            throw new ValidationException('includeAttachments', $includeAttachments);
449
        } else {
450
            if($includeAttachments) {
451
                array_push($this->includes, 'attachments');
452
            }
453
        }
454
455
        // Validate $includeTickets;
456
        if (!$this->validator->validInclude($includeLocation)) {
457
            throw new ValidationException('includeLocation', $includeLocation);
458
        } else {
459
            if($includeLocation) {
460
                array_push($this->includes, 'location');
461
            }
462
        }
463
464
        // Validate $includeTickets;
465
        if (!$this->validator->validInclude($includeTickets)) {
466
            throw new ValidationException('includeTickets', $includeTickets);
467
        } else {
468
            if($includeTickets) {
469
                array_push($this->includes, 'tickets');
470
            }
471
        }
472
473
        // Validate $includeTicketsEvents;
474
        if (!$this->validator->validInclude($includeTicketsEvents)) {
475
            throw new ValidationException('includeTicketsEvents', $includeTicketsEvents);
476
        } else {
477
            if($includeTickets) {
478
                array_push($this->includes, 'tickets.events');
479
            }
480
        }
481
482
        // Validate $includeTicketsClassPasses;
483
        if (!$this->validator->validInclude($includeTicketsClassPasses)) {
484
            throw new ValidationException('includeTicketsClassPasses', $includeTicketsClassPasses);
485
        } else {
486
            if($includeTicketsClassPasses) {
487
                array_push($this->includes, 'tickets.class_passes');
488
            }
489
        }
490
491
        $events = $this->client->events()->list(array_merge($this->filters, ['include' => implode(',', $this->includes)]));
492
493
        $eventAttachments = [];
494
495
        $eventTickets = [];
496
497
        foreach ($events->data as $event) {
498
            array_push($this->events, new Event(
499
                $event->allDay,
500
                $eventAttachments,
501
                $event->attendeeCount,
502
                $event->attendeeLimit,
503
                $event->details,
504
                $event->endAt,
505
                $event->id,
506
                new Location(
507
                    null,
508
                    null,
509
                    $event->locationId,
510
                ),
511
                $event->maxTicketsPerBooking,
512
                $event->startAt,
513
                $eventTickets,
514
                $event->title,
515
                $event->waitingList
516
            ));
517
        }
518
519
        return $this->events;
520
    }
521
522
    /*
523
     *
524
     * {@inheritDoc}
525
     * @see \InShore\Bookwhen\Interfaces\ClientInterface::getLocation()
526
     */
527
    public function location(string $locationId): Location
528
    {
529
530
        if (!$this->validator->validId($locationId, 'location')) {
531
            throw new ValidationException('locationId', $locationId);
532
        }
533
534
        $location = $this->client->locations()->retrieve($locationId);
535
536
        return $this->location = new Location(
0 ignored issues
show
Bug introduced by
The property location is declared read-only in InShore\Bookwhen\Bookwhen.
Loading history...
537
            $location->additionalInfo,
538
            $location->addressText,
539
            $location->id,
540
            $location->latitude,
541
            $location->longitude,
542
            $location->mapUrl,
543
            $location->zoom
544
        );
545
    }
546
547
    /**
548
     *
549
     * {@inheritDoc}
550
     * @see \InShore\Bookwhen\Interfaces\ClientInterface::getLocations()
551
     * @todo validate params.
552
     */
553
    public function locations(
554
        null | string $addressText = null,
555
        null | string $additionalInfo = null
556
    ): array {
557
558
        // $this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')');
559
560
        if (!$this->validator->validId($eventId, 'event')) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $eventId seems to be never defined.
Loading history...
561
            throw new ValidationException('eventId', $eventId);
562
        }
563
564
        $locations = $this->client->locations()->list();
565
566
        foreach ($locations->data as $location) {
567
            array_push($this->locations, new Location(
568
                $location->additionalInfo,
569
                $location->addressText,
570
                $location->id,
571
                $location->latitude,
572
                $location->longitude,
573
                $location->mapUrl,
574
                $location->zoom
575
            ));
576
        }
577
578
        return $this->locations;
579
580
    }
581
582
    /**
583
     * Set Debug.
584
     * @deprecated
585
     */
586
    public function setLogging($level)
587
    {
588
        $this->logging = $level;
0 ignored issues
show
Bug Best Practice introduced by
The property logging does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
589
    }
590
591
     /**
592
     * Sets the token for all future new instances
593
     * @deprecated
594
     * @param $token string The API access token, as obtained on diffbot.com/dev.
595
     */
596
    public static function setToken($token)
597
    {
598
        $validator = new Validator();
599
        if (!$validator->validToken($token)) {
600
            throw new \InvalidArgumentException('Invalid Token.');
601
        }
602
        self::$token = $token;
0 ignored issues
show
Bug Best Practice introduced by
The property token does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
603
    }
604
605
    /**
606
     * {@inheritDoc}
607
     * @see \InShore\Bookwhen\Interfaces\BookWhenInterface::ticket()
608
     */
609
    public function ticket($ticketId): Ticket
610
    {
611
        if (!$this->validator->validId($ticketId, 'ticket')) {
612
            throw new ValidationException('ticketId', $ticketId);
613
        }
614
615
        $ticket = $this->client->tickets()->retrieve($ticketId);
616
617
        return $this->ticket = new Ticket(
618
            $ticket->available,
619
            $ticket->availableFrom,
620
            $ticket->availableTo,
621
            $ticket->builtBasketUrl,
622
            $ticket->builtBasketIframeUrl,
623
            $ticket->courseTicket,
624
            $ticket->details,
625
            $ticket->groupTicket,
626
            $ticket->groupMin,
627
            $ticket->groupMax,
628
            $ticket->id,
629
            $ticket->numberIssued,
630
            $ticket->numberTaken,
631
            $ticket->title
632
        );
633
    }
634
635
    /**
636
     * {@inheritDoc}
637
     * @see \InShore\Bookwhen\Interfaces\BookWhenInterface::tickets()
638
     * @todo includes
639
     */
640
    public function tickets(string $eventId): array
641
    {
642
        // $this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')');
643
644
        if (!$this->validator->validId($eventId, 'event')) {
645
            throw new ValidationException('eventId', $eventId);
646
        }
647
648
        $tickets = $this->client->tickets()->list([
649
            'event_id' => $eventId,
650
            'include' => 'events.tickets'
651
        ]);
652
653
        foreach ($tickets->data as $ticket) {
654
            array_push($this->tickets, new Ticket(
655
                $ticket->available,
656
                $ticket->availableFrom,
657
                $ticket->availableTo,
658
                $ticket->builtBasketUrl,
659
                $ticket->builtBasketIframeUrl,
660
                $ticket->courseTicket,
661
                $ticket->details,
662
                $ticket->groupTicket,
663
                $ticket->groupMin,
664
                $ticket->groupMax,
665
                $ticket->id,
666
                $ticket->numberIssued,
667
                $ticket->numberTaken,
668
                $ticket->title
669
            ));
670
        }
671
672
        return $this->tickets;
673
674
    }
675
}
676