TicketControllerExtension::TicketForm()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 2
nop 0
1
<?php
2
/**
3
 * TicketControllerExtension.php
4
 *
5
 * @author Bram de Leeuw
6
 * Date: 09/03/17
7
 */
8
9
namespace Broarm\EventTickets;
10
11
use CalendarEvent_Controller;
12
use Extension;
13
14
/**
15
 * Class TicketControllerExtension
16
 *
17
 * @package Broarm\EventTickets
18
 *
19
 * @property TicketControllerExtension|TicketExtension|CalendarEvent_Controller $owner
20
 */
21
class TicketControllerExtension extends Extension
22
{
23
    private static $allowed_actions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
24
        'TicketForm',
25
        'WaitingListRegistrationForm',
26
        'checkin'
27
    );
28
29
    /**
30
     * Get the ticket form with available tickets
31
     *
32
     * @return TicketForm
0 ignored issues
show
Documentation introduced by
Should the return type not be TicketForm|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
33
     */
34
    public function TicketForm()
35
    {
36
        if ($this->owner->Tickets()->count() && $this->owner->getTicketsAvailable()) {
37
            $ticketForm = new TicketForm($this->owner, 'TicketForm', $this->owner->Tickets(), $this->owner->dataRecord);
38
            $ticketForm->setNextStep(CheckoutSteps::start());
39
            return $ticketForm;
40
        } else {
41
            return null;
42
        }
43
    }
44
45
    /**
46
     * show the waiting list form when the event is sold out
47
     *
48
     * @return WaitingListRegistrationForm
0 ignored issues
show
Documentation introduced by
Should the return type not be WaitingListRegistrationForm|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
49
     */
50
    public function WaitingListRegistrationForm()
51
    {
52
        if (
53
            $this->owner->Tickets()->count()
54
            && $this->owner->getTicketsSoldOut()
55
            && !$this->owner->getEventExpired()
56
        ) {
57
            return new WaitingListRegistrationForm($this->owner, 'WaitingListRegistrationForm');
58
        } else {
59
            return null;
60
        }
61
    }
62
63
    /**
64
     * Go to the check in controller
65
     *
66
     * @return CheckInController
67
     */
68
    public function checkIn()
69
    {
70
        return new CheckInController($this->owner->dataRecord);
71
    }
72
73
    /**
74
     * Checks the waiting list var
75
     *
76
     * @return mixed
77
     */
78
    public function getWaitingListSuccess()
79
    {
80
        return $this->owner->getRequest()->getVar('waitinglist');
81
    }
82
}
83