Completed
Push — master ( 566e3d...cbf465 )
by Ariel
06:35
created

TimetableStrategy::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 3
eloc 10
nc 3
nop 1
1
<?php
2
3
namespace Timegridio\Concierge\Timetable\Strategies;
4
5
use Timegridio\Concierge\Exceptions\StrategyNotRecognizedException;
6
use Timegridio\Concierge\Timetable\Timetable;
7
8
class TimetableStrategy
9
{
10
    /**
11
     * Timetable Strategy.
12
     *
13
     * @var TimetableTimeslotStrategy|TimetableDateslotStrategy
14
     */
15
    protected $strategy = null;
16
17
    /**
18
     * Construct Timetable Strategy class.
19
     *
20
     * @param string $strategyId
21
     *
22
     * @throws  Timegridio\Concierge\Exceptions\StrategyNotRecognizedException
23
     */
24
    public function __construct($strategyId)
25
    {
26
        switch ($strategyId) {
27
            case 'timeslot':
28
                $this->strategy = new TimetableTimeslotStrategy(new Timetable());
29
                break;
30
            case 'dateslot':
31
                $this->strategy = new TimetableDateslotStrategy(new Timetable());
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Timegridio\Concierg...\Timetable\Timetable()) of type object<Timegridio\Concie...etableDateslotStrategy> is incompatible with the declared type object<Timegridio\Concie...etableTimeslotStrategy> 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...
32
                break;
33
            default:
34
                throw new StrategyNotRecognizedException($strategyId);
35
        }
36
    }
37
38
    public function buildTimetable($vacancies, $starting = 'today', $days = 1)
39
    {
40
        return $this->strategy->buildTimetable($vacancies, $starting, $days);
41
    }
42
}
43