Completed
Push — master ( f4beca...50d318 )
by Ariel
06:18
created

BookingDateslotStrategy::hasRoom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Timegridio\Concierge\Booking\Strategies;
4
5
use Carbon\Carbon;
6
use Timegridio\Concierge\Models\Appointment;
7
use Timegridio\Concierge\Models\Business;
8
use Timegridio\Concierge\Models\Contact;
9
use Timegridio\Concierge\Models\Service;
10
11
class BookingDateslotStrategy implements BookingStrategyInterface
12
{
13
    public function generateAppointment(
14
        $issuerId,
15
        Business $business,
16
        Contact $contact,
17
        Service $service,
18
        Carbon $datetime,
19
        $comments = null
20
    ) {
21
        $appointment = new Appointment();
22
23
        $appointment->doReserve();
24
        $appointment->setStartAtAttribute($datetime);
25
        $appointment->business()->associate($business);
26
        $appointment->issuer()->associate($issuerId);
27
        $appointment->contact()->associate($contact);
28
        $appointment->service()->associate($service);
29
        $appointment->comments = $comments;
0 ignored issues
show
Documentation introduced by
The property comments does not exist on object<Timegridio\Concierge\Models\Appointment>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
30
        $appointment->doHash();
31
32
        return $appointment;
33
    }
34
}
35