| Total Complexity | 109 |
| Total Lines | 858 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
Complex classes like Bookwhen often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Bookwhen, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 21 | final class Bookwhen implements BookwhenInterface |
||
| 22 | { |
||
| 23 | private null | Client $client; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * |
||
| 27 | * @var unknown |
||
|
|
|||
| 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; |
||
| 95 | |||
| 96 | /** @var object loging object. */ |
||
| 97 | private $logger; |
||
| 98 | |||
| 99 | /** @var string the logging level. */ |
||
| 100 | private string $logLevel; |
||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | /** |
||
| 105 | * Creates a new Bookwhen Client with the given API token. |
||
| 106 | * @todo logging |
||
| 107 | */ |
||
| 108 | public function __construct( |
||
| 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); |
||
| 131 | |||
| 132 | return $this->attachment = new Attachment( |
||
| 133 | $attachment->contentType, |
||
| 134 | $attachment->fileUrl, |
||
| 135 | $attachment->fileSizeBytes, |
||
| 136 | $attachment->fileSizeText, |
||
| 137 | $attachment->fileName, |
||
| 138 | $attachment->fileType, |
||
| 139 | $attachment->id, |
||
| 140 | $attachment->title, |
||
| 141 | ); |
||
| 142 | } |
||
| 143 | |||
| 144 | /** |
||
| 145 | * |
||
| 146 | * {@inheritDoc} |
||
| 147 | * @see \InShore\Bookwhen\Interfaces\BookwhenInterface::attachment() |
||
| 148 | * @todo |
||
| 149 | */ |
||
| 150 | public function attachments( |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * |
||
| 195 | * {@inheritDoc} |
||
| 196 | * @see \InShore\Bookwhen\Interfaces\ClientInterface::getClassPass() |
||
| 197 | * @todo |
||
| 198 | */ |
||
| 199 | public function classPass(string $classPassId): ClassPass |
||
| 200 | { |
||
| 201 | // $this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')'); |
||
| 202 | |||
| 203 | if (!$this->validator->validId($classPassId, 'classPass')) { |
||
| 204 | throw new ValidationException('classPassId', $classPassId); |
||
| 205 | } |
||
| 206 | |||
| 207 | $classPass = $this->client->classPasses()->retrieve($classPassId); |
||
| 208 | |||
| 209 | return new ClassPass( |
||
| 210 | $classPass->details, |
||
| 211 | $classPass->id, |
||
| 212 | $classPass->numberAvailable, |
||
| 213 | $classPass->title, |
||
| 214 | $classPass->usageAllowance, |
||
| 215 | $classPass->usageType, |
||
| 216 | $classPass->useRestrictedForDays |
||
| 217 | ); |
||
| 218 | } |
||
| 219 | |||
| 220 | /** |
||
| 221 | * |
||
| 222 | * {@inheritDoc} |
||
| 223 | * @see \InShore\Bookwhen\Interfaces\ClientInterface::getClassPasses() |
||
| 224 | * @todo break params on to multiplper lines.. |
||
| 225 | */ |
||
| 226 | public function classPasses( |
||
| 227 | $cost = null, |
||
| 228 | $detail = null, |
||
| 229 | $title = null, |
||
| 230 | $usageAllowance = null, |
||
| 231 | $usageType = null, |
||
| 232 | $useRestrictedForDays = null |
||
| 233 | ): array { |
||
| 234 | |||
| 235 | //$this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')'); |
||
| 236 | |||
| 237 | if (!is_null($detail) && !$this->validator->validDetails($detail)) { |
||
| 238 | throw new ValidationException('detail', $detail); |
||
| 239 | } else { |
||
| 240 | $this->filters['filter[detail]'] = $detail; |
||
| 241 | } |
||
| 242 | |||
| 243 | if (!is_null($title) && !$this->validator->validTitle($title)) { |
||
| 244 | throw new ValidationException('title', $title); |
||
| 245 | } else { |
||
| 246 | $this->filters['filter[title]'] = $title; |
||
| 247 | } |
||
| 248 | |||
| 249 | if (!is_null($usageAllowance) && !$this->validator->validUsageAllowance($usageAllowance)) { |
||
| 250 | throw new ValidationException('usageAllowance', $usageAllowance); |
||
| 251 | } else { |
||
| 252 | $this->filters['filter[usage_allowance]'] = $usageAllowance; |
||
| 253 | } |
||
| 254 | |||
| 255 | if (!is_null($usageType) && !$this->validator->validUsageType($usageType)) { |
||
| 256 | throw new ValidationException('usageType', $usageType); |
||
| 257 | } else { |
||
| 258 | $this->filters['filter[usage_type]'] = $usageType; |
||
| 259 | } |
||
| 260 | |||
| 261 | if (!is_null($useRestrictedForDays) && !$this->validator->validUseRestrictedForDays($useRestrictedForDays)) { |
||
| 262 | throw new ValidationException('useRestrictedForDays', $useRestrictedForDays); |
||
| 263 | } else { |
||
| 264 | $this->filters['filter[use_restricted_for_days]'] = $useRestrictedForDays; |
||
| 265 | } |
||
| 266 | |||
| 267 | $classPasses = $this->client->classPasses()->list($this->filters); |
||
| 268 | |||
| 269 | foreach ($classPasses->data as $classPass) { |
||
| 270 | array_push($this->classPasses, new ClassPass( |
||
| 271 | $classPass->details, |
||
| 272 | $classPass->id, |
||
| 273 | $classPass->numberAvailable, |
||
| 274 | $classPass->title, |
||
| 275 | $classPass->usageAllowance, |
||
| 276 | $classPass->usageType, |
||
| 277 | $classPass->useRestrictedForDays, |
||
| 278 | )); |
||
| 279 | } |
||
| 280 | return $this->classPasses; |
||
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * |
||
| 285 | * {@inheritDoc} |
||
| 286 | * @see \InShore\Bookwhen\Interfaces\BookwhenInterface::event() |
||
| 287 | * @todo filters. |
||
| 288 | */ |
||
| 289 | public function event( |
||
| 290 | string $eventId, |
||
| 291 | bool $includeAttachments = false, |
||
| 292 | bool $includeLocation = false, |
||
| 293 | bool $includeTickets = false, |
||
| 294 | bool $includeTicketsClassPasses = false, |
||
| 295 | bool $includeTicketsEvents = false |
||
| 296 | ): Event { |
||
| 297 | //$this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')'); |
||
| 298 | |||
| 299 | if (!$this->validator->validId($eventId, 'event')) { |
||
| 300 | throw new ValidationException('eventId', $eventId); |
||
| 301 | } |
||
| 302 | |||
| 303 | // Validate $includeAttachments; |
||
| 304 | if (!$this->validator->validInclude($includeAttachments)) { |
||
| 305 | throw new ValidationException('includeAttachments', $includeAttachments); |
||
| 306 | } else { |
||
| 307 | if($includeAttachments) { |
||
| 308 | array_push($this->includes, 'attachments'); |
||
| 309 | } |
||
| 310 | } |
||
| 311 | |||
| 312 | // Validate $includeTickets; |
||
| 313 | if (!$this->validator->validInclude($includeLocation)) { |
||
| 314 | throw new ValidationException('includeLocation', $includeLocation); |
||
| 315 | } else { |
||
| 316 | if($includeLocation) { |
||
| 317 | array_push($this->includes, 'location'); |
||
| 318 | } |
||
| 319 | } |
||
| 320 | |||
| 321 | // Validate $includeTickets; |
||
| 322 | if (!$this->validator->validInclude($includeTickets)) { |
||
| 323 | throw new ValidationException('includeTickets', $includeTickets); |
||
| 324 | } else { |
||
| 325 | if($includeTickets) { |
||
| 326 | array_push($this->includes, 'tickets'); |
||
| 327 | } |
||
| 328 | } |
||
| 329 | |||
| 330 | // Validate $includeTicketsEvents; |
||
| 331 | if (!$this->validator->validInclude($includeTicketsEvents)) { |
||
| 332 | throw new ValidationException('includeTicketsEvents', $includeTicketsEvents); |
||
| 333 | } else { |
||
| 334 | if($includeTicketsEvents) { |
||
| 335 | array_push($this->includes, 'tickets.events'); |
||
| 336 | } |
||
| 337 | } |
||
| 338 | |||
| 339 | // Validate $includeTicketsClassPasses; |
||
| 340 | if (!$this->validator->validInclude($includeTicketsClassPasses)) { |
||
| 341 | throw new ValidationException('includeTicketsClassPasses', $includeTicketsClassPasses); |
||
| 342 | } else { |
||
| 343 | if($includeTicketsClassPasses) { |
||
| 344 | array_push($this->includes, 'tickets.class_passes'); |
||
| 345 | } |
||
| 346 | } |
||
| 347 | |||
| 348 | $event = $this->client->events()->retrieve($eventId, ['include' => implode(',', $this->includes)]); |
||
| 349 | |||
| 350 | // attachments |
||
| 351 | $eventAttachments = []; |
||
| 352 | |||
| 353 | foreach ($event->attachments as $eventAttachment) { |
||
| 354 | $attachment = $this->client->attachments()->retrieve($eventAttachment['id']); |
||
| 355 | array_push($eventAttachments, new Attachment( |
||
| 356 | $attachment->contentType, |
||
| 357 | $attachment->fileUrl, |
||
| 358 | $attachment->fileSizeBytes, |
||
| 359 | $attachment->fileSizeText, |
||
| 360 | $attachment->fileName, |
||
| 361 | $attachment->fileType, |
||
| 362 | $attachment->id, |
||
| 363 | $attachment->title |
||
| 364 | )); |
||
| 365 | } |
||
| 366 | |||
| 367 | // eventTickets |
||
| 368 | $eventTickets = []; |
||
| 369 | foreach($event->tickets as $ticket) { |
||
| 370 | array_push($eventTickets, new Ticket( |
||
| 371 | $ticket->available, |
||
| 372 | $ticket->availableFrom, |
||
| 373 | $ticket->availableTo, |
||
| 374 | $ticket->builtBasketUrl, |
||
| 375 | $ticket->builtBasketIframeUrl, |
||
| 376 | $ticket->courseTicket, |
||
| 377 | $ticket->details, |
||
| 378 | $ticket->groupTicket, |
||
| 379 | $ticket->groupMin, |
||
| 380 | $ticket->groupMax, |
||
| 381 | $ticket->id, |
||
| 382 | $ticket->numberIssued, |
||
| 383 | $ticket->numberTaken, |
||
| 384 | $ticket->title |
||
| 385 | )); |
||
| 386 | } |
||
| 387 | |||
| 388 | // ticketsClassPasses |
||
| 389 | // @todo |
||
| 390 | |||
| 391 | // ticketsEvents |
||
| 392 | // @todo |
||
| 393 | |||
| 394 | return $this->event = new Event( |
||
| 395 | $event->allDay, |
||
| 396 | $eventAttachments, |
||
| 397 | $event->attendeeCount, |
||
| 398 | $event->attendeeLimit, |
||
| 399 | $event->details, |
||
| 400 | $event->endAt, |
||
| 401 | $event->id, |
||
| 402 | new Location( |
||
| 403 | $event->location->addressText, |
||
| 404 | $event->location->additionalInfo, |
||
| 405 | $event->location->id, |
||
| 406 | $event->location->latitude, |
||
| 407 | $event->location->longitude, |
||
| 408 | $event->location->mapUrl, |
||
| 409 | $event->location->zoom |
||
| 410 | ), |
||
| 411 | $event->maxTicketsPerBooking, |
||
| 412 | $event->startAt, |
||
| 413 | $eventTickets, |
||
| 414 | $event->title, |
||
| 415 | $event->waitingList |
||
| 416 | ); |
||
| 417 | } |
||
| 418 | |||
| 419 | /** |
||
| 420 | * |
||
| 421 | * {@inheritDoc} |
||
| 422 | * @see \InShore\Bookwhen\Interfaces\ClientInterface::getEvents() |
||
| 423 | */ |
||
| 424 | public function events( |
||
| 425 | $calendar = false, |
||
| 426 | $entry = false, |
||
| 427 | $location = [], |
||
| 428 | $tags = [], |
||
| 429 | $title = [], |
||
| 430 | $detail = [], |
||
| 431 | $from = null, |
||
| 432 | $to = null, |
||
| 433 | bool $includeAttachments = false, |
||
| 434 | bool $includeLocation = false, |
||
| 435 | bool $includeTickets = false, |
||
| 436 | bool $includeTicketsClassPasses = false, |
||
| 437 | bool $includeTicketsEvents = false |
||
| 438 | ): array { |
||
| 439 | |||
| 440 | //$this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')'); |
||
| 441 | |||
| 442 | // Validate $calendar |
||
| 443 | // @todo details required |
||
| 444 | |||
| 445 | // Validate $detail |
||
| 446 | if (!empty($detail)) { |
||
| 447 | if (!is_array($detail)) { |
||
| 448 | throw new ValidationException('detail', implode(' ', $detail)); |
||
| 449 | } else { |
||
| 450 | $detail = array_unique($detail); |
||
| 451 | foreach($detail as $item) { |
||
| 452 | if (!$this->validator->validLocation($item)) { |
||
| 453 | throw new ValidationException('detail', $item); |
||
| 454 | } |
||
| 455 | } |
||
| 456 | $this->filters['filter[detail]'] = implode(',', $detail); |
||
| 457 | } |
||
| 458 | } |
||
| 459 | |||
| 460 | // Validate $entry |
||
| 461 | // @todo details required |
||
| 462 | |||
| 463 | // Validate $from; |
||
| 464 | if (!empty($from)) { |
||
| 465 | if (!$this->validator->validFrom($from, $to)) { |
||
| 466 | throw new ValidationException('from', $from . '-' . $to); |
||
| 467 | } else { |
||
| 468 | $this->filters['filter[from]'] = $from; |
||
| 469 | } |
||
| 470 | } |
||
| 471 | |||
| 472 | // Validate $location |
||
| 473 | if (!empty($location)) { |
||
| 474 | if (!is_array($location)) { |
||
| 475 | throw new ValidationException('location', implode(' ', $title)); |
||
| 476 | } else { |
||
| 477 | $location = array_unique($location); |
||
| 478 | foreach($location as $item) { |
||
| 479 | if (!$this->validator->validLocation($item)) { |
||
| 480 | throw new ValidationException('location', $item); |
||
| 481 | } |
||
| 482 | } |
||
| 483 | $this->filters['filter[location]'] = implode(',', $location); |
||
| 484 | } |
||
| 485 | } |
||
| 486 | |||
| 487 | // Validate $tags. |
||
| 488 | if (!empty($tags)) { |
||
| 489 | if (!is_array($tags)) { |
||
| 490 | throw new ValidationException('tags', implode(' ', $tags)); |
||
| 491 | } else { |
||
| 492 | $tags = array_unique($tags); |
||
| 493 | foreach ($tags as $tag) { |
||
| 494 | if (!empty($tag) && !$this->validator->validTag($tag)) { |
||
| 495 | throw new ValidationException('tag', $tag); |
||
| 496 | } |
||
| 497 | } |
||
| 498 | } |
||
| 499 | $this->filters['filter[tag]'] = implode(',', $tags); |
||
| 500 | } |
||
| 501 | |||
| 502 | // Validate $title; |
||
| 503 | if (!empty($title)) { |
||
| 504 | if (!is_array($title)) { |
||
| 505 | throw new ValidationException('title', implode(' ', $title)); |
||
| 506 | } else { |
||
| 507 | $title = array_unique($title); |
||
| 508 | foreach($title as $item) { |
||
| 509 | if (!$this->validator->validTitle($item)) { |
||
| 510 | throw new ValidationException('title', $item); |
||
| 511 | } |
||
| 512 | } |
||
| 513 | $this->filters['filter[title]'] = implode(',', $title); |
||
| 514 | } |
||
| 515 | } |
||
| 516 | |||
| 517 | // Validate $to; |
||
| 518 | if (!empty($to)) { |
||
| 519 | if (!$this->validator->validTo($to, $from)) { |
||
| 520 | throw new ValidationException('to', $to . '-' . $from); |
||
| 521 | } else { |
||
| 522 | $this->filters['filter[to]'] = $to; |
||
| 523 | } |
||
| 524 | } |
||
| 525 | |||
| 526 | // Validate $includeAttachments; |
||
| 527 | if (!$this->validator->validInclude($includeAttachments)) { |
||
| 528 | throw new ValidationException('includeAttachments', $includeAttachments); |
||
| 529 | } else { |
||
| 530 | if($includeAttachments) { |
||
| 531 | array_push($this->includes, 'attachments'); |
||
| 532 | } |
||
| 533 | } |
||
| 534 | |||
| 535 | // Validate $includeTickets; |
||
| 536 | if (!$this->validator->validInclude($includeLocation)) { |
||
| 537 | throw new ValidationException('includeLocation', $includeLocation); |
||
| 538 | } else { |
||
| 539 | if($includeLocation) { |
||
| 540 | array_push($this->includes, 'location'); |
||
| 541 | } |
||
| 542 | } |
||
| 543 | |||
| 544 | // Validate $includeTickets; |
||
| 545 | if (!$this->validator->validInclude($includeTickets)) { |
||
| 546 | throw new ValidationException('includeTickets', $includeTickets); |
||
| 547 | } else { |
||
| 548 | if($includeTickets) { |
||
| 549 | array_push($this->includes, 'tickets'); |
||
| 550 | } |
||
| 551 | } |
||
| 552 | |||
| 553 | // Validate $includeTicketsEvents; |
||
| 554 | if (!$this->validator->validInclude($includeTicketsEvents)) { |
||
| 555 | throw new ValidationException('includeTicketsEvents', $includeTicketsEvents); |
||
| 556 | } else { |
||
| 557 | if($includeTicketsEvents) { |
||
| 558 | array_push($this->includes, 'tickets.events'); |
||
| 559 | } |
||
| 560 | } |
||
| 561 | |||
| 562 | // Validate $includeTicketsClassPasses; |
||
| 563 | if (!$this->validator->validInclude($includeTicketsClassPasses)) { |
||
| 564 | throw new ValidationException('includeTicketsClassPasses', $includeTicketsClassPasses); |
||
| 565 | } else { |
||
| 566 | if($includeTicketsClassPasses) { |
||
| 567 | array_push($this->includes, 'tickets.class_passes'); |
||
| 568 | } |
||
| 569 | } |
||
| 570 | |||
| 571 | $events = $this->client->events()->list(array_merge($this->filters, ['include' => implode(',', $this->includes)])); |
||
| 572 | |||
| 573 | foreach ($events->data as $event) { |
||
| 574 | |||
| 575 | $eventTickets = []; |
||
| 576 | foreach($event->tickets as $ticket) { |
||
| 577 | array_push($eventTickets, new Ticket( |
||
| 578 | $ticket->available, |
||
| 579 | $ticket->availableFrom, |
||
| 580 | $ticket->availableTo, |
||
| 581 | $ticket->builtBasketUrl, |
||
| 582 | $ticket->builtBasketIframeUrl, |
||
| 583 | $ticket->courseTicket, |
||
| 584 | $ticket->details, |
||
| 585 | $ticket->groupTicket, |
||
| 586 | $ticket->groupMin, |
||
| 587 | $ticket->groupMax, |
||
| 588 | $ticket->id, |
||
| 589 | $ticket->numberIssued, |
||
| 590 | $ticket->numberTaken, |
||
| 591 | $ticket->title |
||
| 592 | )); |
||
| 593 | } |
||
| 594 | |||
| 595 | array_push($this->events, new Event( |
||
| 596 | $event->allDay, |
||
| 597 | $event->attachments, |
||
| 598 | $event->attendeeCount, |
||
| 599 | $event->attendeeLimit, |
||
| 600 | $event->details, |
||
| 601 | $event->endAt, |
||
| 602 | $event->id, |
||
| 603 | new Location( |
||
| 604 | $event->location->addressText, |
||
| 605 | $event->location->additionalInfo, |
||
| 606 | $event->location->id, |
||
| 607 | $event->location->latitude, |
||
| 608 | $event->location->longitude, |
||
| 609 | $event->location->mapUrl, |
||
| 610 | $event->location->zoom |
||
| 611 | ), |
||
| 612 | $event->maxTicketsPerBooking, |
||
| 613 | $event->startAt, |
||
| 614 | $eventTickets, |
||
| 615 | $event->title, |
||
| 616 | $event->waitingList |
||
| 617 | )); |
||
| 618 | } |
||
| 619 | |||
| 620 | return $this->events; |
||
| 621 | } |
||
| 622 | |||
| 623 | /* |
||
| 624 | * |
||
| 625 | * {@inheritDoc} |
||
| 626 | * @see \InShore\Bookwhen\Interfaces\ClientInterface::getLocation() |
||
| 627 | */ |
||
| 628 | public function location(string $locationId): Location |
||
| 629 | { |
||
| 630 | |||
| 631 | if (!$this->validator->validId($locationId, 'location')) { |
||
| 632 | throw new ValidationException('locationId', $locationId); |
||
| 633 | } |
||
| 634 | |||
| 635 | $location = $this->client->locations()->retrieve($locationId); |
||
| 636 | |||
| 637 | return $this->location = new Location( |
||
| 638 | $location->additionalInfo, |
||
| 639 | $location->addressText, |
||
| 640 | $location->id, |
||
| 641 | $location->latitude, |
||
| 642 | $location->longitude, |
||
| 643 | $location->mapUrl, |
||
| 644 | $location->zoom |
||
| 645 | ); |
||
| 646 | } |
||
| 647 | |||
| 648 | /** |
||
| 649 | * |
||
| 650 | */ |
||
| 651 | public function locations( |
||
| 652 | null | string $addressText = null, |
||
| 653 | null | string $additionalInfo = null |
||
| 654 | ): array { |
||
| 655 | |||
| 656 | // $this->logger->debug(__METHOD__ . '(' . var_export(func_get_args(), true) . ')'); |
||
| 657 | |||
| 658 | if (!empty($additionalInfo)) { |
||
| 659 | if (!$this->validator->validAdditionalInfo($additionalInfo, 'additionalInfo')) { |
||
| 660 | throw new ValidationException('additionalInfo', $additionalInfo); |
||
| 661 | } |
||
| 662 | $this->filters['filter[additional_info]'] = $additionalInfo; |
||
| 663 | } |
||
| 664 | |||
| 665 | if (!empty($addressText)) { |
||
| 666 | if (!$this->validator->validAddressText($addressText, 'addressText')) { |
||
| 667 | throw new ValidationException('addressText', $addressText); |
||
| 668 | } |
||
| 669 | $this->filters['filter[address_text]'] = $addressText; |
||
| 670 | } |
||
| 671 | |||
| 672 | $locations = $this->client->locations()->list($this->filters); |
||
| 673 | |||
| 674 | foreach ($locations->data as $location) { |
||
| 675 | array_push($this->locations, new Location( |
||
| 676 | $location->additionalInfo, |
||
| 677 | $location->addressText, |
||
| 678 | $location->id, |
||
| 679 | $location->latitude, |
||
| 680 | $location->longitude, |
||
| 681 | $location->mapUrl, |
||
| 682 | $location->zoom |
||
| 683 | )); |
||
| 684 | } |
||
| 685 | |||
| 686 | return $this->locations; |
||
| 687 | |||
| 688 | } |
||
| 689 | |||
| 690 | /** |
||
| 691 | * Set Debug. |
||
| 692 | * @deprecated |
||
| 693 | */ |
||
| 694 | public function setLogging($level) |
||
| 695 | { |
||
| 696 | $this->logging = $level; |
||
| 697 | } |
||
| 698 | |||
| 699 | /** |
||
| 700 | * Sets the token for all future new instances |
||
| 701 | * @deprecated |
||
| 702 | * @param $token string The API access token, as obtained on diffbot.com/dev. |
||
| 703 | */ |
||
| 704 | public static function setToken($token) |
||
| 705 | { |
||
| 706 | $validator = new Validator(); |
||
| 707 | if (!$validator->validToken($token)) { |
||
| 708 | throw new \InvalidArgumentException('Invalid Token.'); |
||
| 709 | } |
||
| 710 | self::$token = $token; |
||
| 711 | } |
||
| 712 | |||
| 713 | /** |
||
| 714 | * {@inheritDoc} |
||
| 715 | * @see \InShore\Bookwhen\Interfaces\BookWhenInterface::ticket() |
||
| 716 | * class_passes |
||
| 717 | */ |
||
| 718 | public function ticket( |
||
| 719 | string $ticketId, |
||
| 720 | bool $includeClassPasses = false, |
||
| 721 | bool $includeEvents = false, |
||
| 722 | bool $includeEventsAttachments = false, |
||
| 723 | bool $includeEventsLocation = false, |
||
| 724 | bool $includeEventsTickets = false |
||
| 725 | ): Ticket { |
||
| 726 | |||
| 727 | // ticketId |
||
| 728 | if (!$this->validator->validId($ticketId, 'ticket')) { |
||
| 729 | throw new ValidationException('ticketId', $ticketId); |
||
| 730 | } |
||
| 731 | |||
| 732 | // Validate $includeClassPasses; |
||
| 733 | if (!$this->validator->validInclude($includeClassPasses)) { |
||
| 734 | throw new ValidationException('includeClassPasses', $includeClassPasses); |
||
| 735 | } |
||
| 736 | |||
| 737 | if($includeClassPasses) { |
||
| 738 | array_push($this->includes, 'class_passes'); |
||
| 739 | } |
||
| 740 | |||
| 741 | // Validate $includeEvents; |
||
| 742 | if (!$this->validator->validInclude($includeEvents)) { |
||
| 743 | throw new ValidationException('includeEvents', $includeEvents); |
||
| 744 | } |
||
| 745 | if($includeEvents) { |
||
| 746 | array_push($this->includes, 'events'); |
||
| 747 | } |
||
| 748 | |||
| 749 | // Validate $includeAttachments; |
||
| 750 | if (!$this->validator->validInclude($includeEventsAttachments)) { |
||
| 751 | throw new ValidationException('includeEventssAttachments', $includeEventsAttachments); |
||
| 752 | } |
||
| 753 | if($includeEventsAttachments) { |
||
| 754 | array_push($this->includes, 'events.attachments'); |
||
| 755 | } |
||
| 756 | |||
| 757 | // Validate $includeEventsLocation; |
||
| 758 | if (!$this->validator->validInclude($includeEventsLocation)) { |
||
| 759 | throw new ValidationException('includeEventsLocation', $includeEventsLocation); |
||
| 760 | } |
||
| 761 | if($includeEventsLocation) { |
||
| 762 | array_push($this->includes, 'events.location'); |
||
| 763 | } |
||
| 764 | |||
| 765 | // Validate $includeEventsTickets; |
||
| 766 | if (!$this->validator->validInclude($includeEventsTickets)) { |
||
| 767 | throw new ValidationException('includeEventsTickets', $includeEventsTickets); |
||
| 768 | } |
||
| 769 | if($includeEventsTickets) { |
||
| 770 | array_push($this->includes, 'events.tickets'); |
||
| 771 | } |
||
| 772 | |||
| 773 | $ticket = $this->client->tickets()->retrieve($ticketId); |
||
| 774 | |||
| 775 | return $this->ticket = new Ticket( |
||
| 776 | $ticket->available, |
||
| 777 | $ticket->availableFrom, |
||
| 778 | $ticket->availableTo, |
||
| 779 | $ticket->builtBasketUrl, |
||
| 780 | $ticket->builtBasketIframeUrl, |
||
| 781 | $ticket->courseTicket, |
||
| 782 | $ticket->details, |
||
| 783 | $ticket->groupTicket, |
||
| 784 | $ticket->groupMin, |
||
| 785 | $ticket->groupMax, |
||
| 786 | $ticket->id, |
||
| 787 | $ticket->numberIssued, |
||
| 788 | $ticket->numberTaken, |
||
| 789 | $ticket->title |
||
| 790 | ); |
||
| 791 | } |
||
| 792 | |||
| 793 | /** |
||
| 794 | * {@inheritDoc} |
||
| 795 | * @see \InShore\Bookwhen\Interfaces\BookWhenInterface::tickets() |
||
| 796 | * @todo includes |
||
| 797 | */ |
||
| 798 | public function tickets( |
||
| 879 | |||
| 880 | } |
||
| 881 | } |
||
| 882 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths