Test Failed
Pull Request — master (#3)
by
unknown
17:36
created

TimetableStrategy::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.072

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 10
cp 0.8
rs 9.8333
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3.072
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 8
    public function __construct($strategyId)
25
    {
26 8
        switch ($strategyId) {
27
            case 'timeslot':
28 5
                $this->strategy = new TimetableTimeslotStrategy(new Timetable());
29 5
                break;
30
            case 'dateslot':
31 1
                $this->strategy = new TimetableDateslotStrategy(new Timetable());
32 1
                break;
33
            default:
34 2
                throw new StrategyNotRecognizedException($strategyId);
35
        }
36 6
    }
37
38 6
    public function buildTimetable($vacancies, $starting = 'today', $days = 1)
39
    {
40 6
        return $this->strategy->buildTimetable($vacancies, $starting, $days);
41
    }
42
}
43