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

TimetableStrategy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 35
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

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 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