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

Calendar::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
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