Completed
Push — master ( 996639...c6213a )
by Bram
02:34
created

Reservation::setMainContact()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

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 3
nc 1
nop 1
1
<?php
2
/**
3
 * Reservation.php
4
 *
5
 * @author Bram de Leeuw
6
 * Date: 09/03/17
7
 */
8
9
namespace Broarm\EventTickets;
10
11
use CalendarEvent;
12
use CalendarEvent_Controller;
13
use DataObject;
14
use Director;
15
use Dompdf\Dompdf;
16
use FieldList;
17
use File;
18
use Folder;
19
use GridField;
20
use GridFieldConfig_RecordViewer;
21
use HasManyList;
22
use ManyManyList;
23
use Member;
24
use ReadonlyField;
25
use SiteConfig;
26
use SSViewer;
27
use Tab;
28
use TabSet;
29
use ViewableData;
30
31
/**
32
 * Class Reservation
33
 *
34
 * @package Broarm\EventTickets
35
 *
36
 * @property string Status
37
 * @property string Title
38
 * @property float  Subtotal
39
 * @property float  Total
40
 * @property string Email todo determine obsolete value
41
 * @property string Comments
42
 * @property string ReservationCode
43
 * @property string Gateway
44
 *
45
 * @property int    EventID
46
 * @property int    MainContactID
47
 *
48
 * @method CalendarEvent|TicketExtension Event
49
 * @method Attendee MainContact
50
 * @method HasManyList Payments
51
 * @method HasManyList Attendees
52
 * @method ManyManyList PriceModifiers
53
 */
54
class Reservation extends DataObject
55
{
56
    /**
57
     * Time to wait before deleting the discarded cart
58
     * Give a string that is parsable by strtotime
59
     *
60
     * @var string
61
     */
62
    private static $delete_after = '+1 week';
1 ignored issue
show
Unused Code introduced by
The property $delete_after is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
63
64
    private static $db = array(
2 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
65
        'Status' => 'Enum("CART,PENDING,PAID,CANCELED","CART")',
66
        'Title' => 'Varchar(255)',
67
        'Subtotal' => 'Currency',
68
        'Total' => 'Currency',
69
        'Email' => 'Varchar(255)',
70
        'Gateway' => 'Varchar(255)',
71
        'Comments' => 'Text',
72
        'ReservationCode' => 'Varchar(255)'
73
    );
74
75
    private static $has_one = 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...
Unused Code introduced by
The property $has_one is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
76
        'Event' => 'CalendarEvent',
77
        //'TicketFile' => 'File',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
78
        'MainContact' => 'Broarm\EventTickets\Attendee'
79
    );
80
81
    private static $has_many = array(
1 ignored issue
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $has_many is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
82
        'Payments' => 'Payment',
83
        'Attendees' => 'Broarm\EventTickets\Attendee.Reservation'
84
    );
85
86
    private static $belongs_many_many = 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...
Unused Code introduced by
The property $belongs_many_many is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
87
        'PriceModifiers' => 'Broarm\EventTickets\PriceModifier'
88
    );
89
90
    private static $indexes = array(
2 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $indexes is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
91
        'ReservationCode' => 'unique("ReservationCode")'
92
    );
93
94
    private static $summary_fields = array(
1 ignored issue
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $summary_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
95
        'Title' => 'Customer',
96
        'Total.Nice' => 'Total',
97
        'State' => 'Status'
98
    );
99
100
    public function getCMSFields()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
101
    {
102
        $fields = new FieldList(new TabSet('Root', $mainTab = new Tab('Main')));
103
        $gridFieldConfig = GridFieldConfig_RecordViewer::create();
104
        $fields->addFieldsToTab('Root.Main', array(
105
            ReadonlyField::create('ReservationCode', _t('Reservation.Code', 'Code')),
106
            ReadonlyField::create('Title', _t('Reservation.MainContact', 'Main contact')),
107
            ReadonlyField::create('Gateway', _t('Reservation.Gateway', 'Gateway')),
108
            ReadonlyField::create('Total', _t('Reservation.Total', 'Total')),
109
            ReadonlyField::create('Comments', _t('Reservation.Comments', 'Comments')),
110
            $reservationFileField = ReadonlyField::create(
111
                'ReservationFile',
112
                _t('Attendee.Reservation', 'Reservation'),
113
                "<a class='readonly' href='{$this->TicketFile()->Link()}' target='_blank'>Download reservation PDF</a>"
0 ignored issues
show
Deprecated Code introduced by
The method Broarm\EventTickets\Reservation::TicketFile() has been deprecated.

This method has been deprecated.

Loading history...
114
            ),
115
            GridField::create('Attendees', 'Attendees', $this->Attendees(), $gridFieldConfig),
0 ignored issues
show
Documentation Bug introduced by
The method Attendees does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
116
            GridField::create('Payments', 'Payments', $this->Payments(), $gridFieldConfig)
0 ignored issues
show
Documentation Bug introduced by
The method Payments does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
117
        ));
118
        $reservationFileField->dontEscape = true;
119
        $fields->addFieldsToTab('Root.Main', array());
120
        $this->extend('updateCMSFields', $fields);
121
        return $fields;
122
    }
123
124
    /**
125
     * @deprecated
126
     * @return mixed
127
     */
128
    public function TicketFile()
129
    {
130
        return $this->Attendees()->first()->TicketFile();
0 ignored issues
show
Documentation Bug introduced by
The method Attendees does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
131
    }
132
133
    public function onBeforeWrite()
134
    {
135
        // Set the title to the name of the reservation holder
136
        $this->Title = $this->getName();
137
138
        // Create a validation code to be used for confirmation and in the barcode
139
        if ($this->exists() && empty($this->ReservationCode)) {
140
            $this->ReservationCode = $this->createReservationCode();
141
        }
142
143
        parent::onBeforeWrite();
144
    }
145
146
    public function onBeforeDelete()
147
    {
148
        // If a reservation is deleted remove the names from the guest list
149
        foreach ($this->Attendees() as $attendee) {
0 ignored issues
show
Documentation Bug introduced by
The method Attendees does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
150
            /** @var Attendee $attendee */
151
            if ($attendee->exists()) {
152
                $attendee->delete();
153
            }
154
        }
155
156
        // Make sure the ticket file is not downloadable
157
        //if ($this->TicketFile()->exists()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
158
        //    $this->TicketFile()->delete();
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
159
        //}
160
161
        // Remove the folder
162
        if ($this->fileFolder()->exists()) {
163
            $this->fileFolder()->delete();
164
        }
165
166
        parent::onBeforeDelete();
167
    }
168
169
    public function singular_name()
170
    {
171
        $name = explode('\\', parent::singular_name());
172
        return trim(end($name));
173
    }
174
175
    /**
176
     * Check if the cart is still in cart state and the delete_after time period has been exceeded
177
     *
178
     * @return bool
179
     */
180
    public function isDiscarded()
181
    {
182
        $deleteAfter = strtotime(self::config()->get('delete_after'), strtotime($this->Created));
183
        return ($this->Status === 'CART') && (time() > $deleteAfter);
184
    }
185
186
    /**
187
     * Get the full name
188
     *
189
     * @return string
190
     */
191
    public function getName()
192
    {
193
        /** @var Attendee $attendee */
194
        if ($this->MainContact()->exists()) {
0 ignored issues
show
Bug introduced by
The method MainContact() does not exist on Broarm\EventTickets\Reservation. Did you maybe mean setMainContact()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
195
            return $this->MainContact()->getName();
0 ignored issues
show
Bug introduced by
The method MainContact() does not exist on Broarm\EventTickets\Reservation. Did you maybe mean setMainContact()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
196
        } else {
197
            return 'new reservation';
198
        }
199
    }
200
201
    /**
202
     * Return the translated state
203
     * @return string
204
     */
205
    public function getState()
206
    {
207
        return _t("Reservation.{$this->Status}", $this->Status);
208
    }
209
210
    /**
211
     * Get the total by querying the sum of attendee ticket prices
212
     *
213
     * @return float
214
     */
215
    public function calculateTotal()
216
    {
217
        $total = $this->Subtotal = $this->Attendees()->leftJoin(
0 ignored issues
show
Documentation Bug introduced by
The method Attendees does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
218
            'Broarm\EventTickets\Ticket',
219
            '`Broarm\EventTickets\Attendee`.`TicketID` = `Broarm\EventTickets\Ticket`.`ID`'
220
        )->sum('Price');
221
222
        // Calculate any price modifications if added
223
        if ($this->PriceModifiers()->exists()) {
0 ignored issues
show
Documentation Bug introduced by
The method PriceModifiers does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
224
            foreach ($this->PriceModifiers() as $priceModifier) {
0 ignored issues
show
Documentation Bug introduced by
The method PriceModifiers does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
225
                $priceModifier->updateTotal($total);
226
            }
227
        }
228
229
        return $this->Total = $total;
230
    }
231
232
    /**
233
     * Safely change to a state
234
     *
235
     * @param $state
236
     */
237
    public function changeState($state)
238
    {
239
        $availableStates = $this->dbObject('Status')->enumValues();
240
        if (in_array($state, $availableStates)) {
241
            $this->Status = $state;
242
        } else {
243
            user_error(_t('Reservation.STATE_CHANGE_ERROR', 'Selected state is not available'));
244
        }
245
    }
246
247
    /**
248
     * Set the main contact id
249
     *
250
     * @param $id
251
     */
252
    public function setMainContact($id) {
253
        $this->MainContactID = $id;
254
        $this->write();
255
    }
256
257
    /**
258
     * Create a reservation code
259
     *
260
     * @return string
261
     */
262
    public function createReservationCode()
263
    {
264
        return uniqid($this->ID);
265
    }
266
267
    /**
268
     * Create the folder for the qr code and ticket file
269
     *
270
     * @return Folder|DataObject|null
271
     */
272
    public function fileFolder()
273
    {
274
        return Folder::find_or_make("/event-tickets/{$this->ReservationCode}/");
275
    }
276
277
    /**
278
     * Generate the qr codes and downloadable pdf
279
     */
280
    public function createFiles()
281
    {
282
        $folder = $folder = $this->fileFolder();
283
        /** @var Attendee $attendee */
284
        foreach ($this->Attendees() as $attendee) {
0 ignored issues
show
Documentation Bug introduced by
The method Attendees does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
285
            $attendee->createQRCode($folder);
286
            $attendee->createTicketFile($folder);
287
        }
288
    }
289
290
    /**
291
     * Create a Printable ticket file
292
     *
293
     * @param Folder $folder
294
     *
295
     * @return File
296
     * /
297
    private function createTicketFile(Folder $folder)
298
    {
299
        // Find or make a folder
300
        $relativeFilePath = "/{$folder->Filename}{$this->ReservationCode}.pdf";
301
        $absoluteFilePath = Director::baseFolder() . $relativeFilePath;
302
303
        if (!$file = File::get()->find('Filename', $relativeFilePath)) {
304
            $file = File::create();
305
            $file->ParentID = $folder->ID;
306
            $file->OwnerID = (Member::currentUser()) ? Member::currentUser()->ID : 0;
307
            $file->Title = $this->ReservationCode;
308
            $file->setFilename($relativeFilePath);
309
            $file->write();
310
        }
311
312
        // Set the template and parse the data
313
        $template = new SSViewer('PrintableTicket');
314
        $html = $template->process($this->getViewableData());
315
316
        // Create a DomPDF instance
317
        $domPDF = new Dompdf();
318
        $domPDF->loadHtml($html);
319
        $domPDF->setPaper('A4');
320
        $domPDF->getOptions()->setDpi(250);
321
        $domPDF->render();
322
323
        // Save the pdf stream as a file
324
        file_put_contents($absoluteFilePath, $domPDF->output());
325
326
        // Attach the ticket file to the Attendee
327
        $this->TicketFileID = $file->ID;
328
        $this->write();
329
330
        return $file;
331
    }*/
332
333
    /**
334
     * Get a viewable data object for this reservation
335
     * For use in the Email and print template
336
     * @deprecated
337
     * @return ViewableData
338
     * /
339
    public function getViewableData()
340
    {
341
        $config = SiteConfig::current_site_config();
342
        $data = $this->Me();
343
        $data->CurrentDate = $this->Event()->getController()->CurrentDate();
344
        $data->Logo = $config->TicketLogo();
345
        $this->extend('updateViewableData', $data);
346
        return $data;
347
    }*/
348
349
    public function canView($member = null)
350
    {
351
        return $this->Event()->canView($member);
0 ignored issues
show
Documentation Bug introduced by
The method Event does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
352
    }
353
354
    public function canEdit($member = null)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
355
    {
356
        return $this->Event()->canEdit($member);
0 ignored issues
show
Documentation Bug introduced by
The method Event does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
357
    }
358
359
    public function canDelete($member = null)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
360
    {
361
        return $this->Event()->canDelete($member);
0 ignored issues
show
Documentation Bug introduced by
The method Event does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
362
    }
363
364
    public function canCreate($member = null)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
365
    {
366
        return $this->Event()->canCreate($member);
0 ignored issues
show
Documentation Bug introduced by
The method Event does not exist on object<Broarm\EventTickets\Reservation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
367
    }
368
}
369