Completed
Push — master ( 6cb927...1b49b3 )
by Ariel
06:13
created

Calendar::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 14
rs 9.4285
cc 3
eloc 10
nc 3
nop 3
1
<?php
2
3
namespace Timegridio\Concierge\Calendar;
4
5
class Calendar
6
{
7
    protected $strategy;
8
9
    public function __construct($strategyName, $vacancies, $timezone = null)
10
    {
11
        switch ($strategyName) {
12
            case 'timeslot':
13
                $this->strategy = new TimeslotCalendar($vacancies, $timezone);
14
                break;
15
            case 'dateslot':
16
                $this->strategy = new DateslotCalendar($vacancies, $timezone);
17
                break;
18
            default:
19
                // Throw exception
20
                break;
21
        }
22
    }
23
24
    public function __call($name, $arguments)
25
    {
26
        if(method_exists($this->strategy, $name))
27
        {
28
            return $this->strategy->$name($arguments);
29
        }
30
31
        // Throw exception
32
        return false;
33
    }
34
}
35