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

Calendar   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 3
A __call() 0 10 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