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

TimetableStrategy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 4
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
A buildTimetable() 0 4 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