Completed
Push — master ( 3cd0a8...94a3ce )
by Ariel
06:26
created

BookingStrategy::generateAppointment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 8
nc 1
nop 6
1
<?php
2
3
namespace Timegridio\Concierge\Booking\Strategies;
4
5
use Carbon\Carbon;
6
use Timegridio\Concierge\Booking\Timetable;
7
use Timegridio\Concierge\Exceptions\StrategyNotRecognizedException;
8
use Timegridio\Concierge\Models\Business;
9
use Timegridio\Concierge\Models\Contact;
10
use Timegridio\Concierge\Models\Service;
11
12
class BookingStrategy
13
{
14
    /**
15
     * Booking Strategy.
16
     *
17
     * @var BookingTimeslotStrategy|BookingDateslotStrategy
18
     */
19
    protected $strategy = null;
20
21
    /**
22
     * Construct Booking Strategy class.
23
     *
24
     * @param string $strategyId
25
     *
26
     * @throws  Timegridio\Concierge\Exceptions\StrategyNotRecognizedException
27
     */
28
    public function __construct($strategyId)
29
    {
30
        switch ($strategyId) {
31
            case 'timeslot':
32
                $this->strategy = new BookingTimeslotStrategy(new Timetable());
33
                break;
34
            case 'dateslot':
35
                $this->strategy = new BookingDateslotStrategy(new Timetable());
0 ignored issues
show
Unused Code introduced by
The call to BookingDateslotStrategy::__construct() has too many arguments starting with new \Timegridio\Concierge\Booking\Timetable().

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.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Documentation Bug introduced by
It seems like new \Timegridio\Concierg...ge\Booking\Timetable()) of type object<Timegridio\Concie...ookingDateslotStrategy> is incompatible with the declared type object<Timegridio\Concie...ookingTimeslotStrategy> of property $strategy.

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...
36
                break;
37
            default:
38
                throw new StrategyNotRecognizedException($strategyId);
39
        }
40
    }
41
42
    public function buildTimetable($vacancies, $starting = 'today', $days = 1)
43
    {
44
        return $this->strategy->buildTimetable($vacancies, $starting, $days);
45
    }
46
}
47