HolidayHelper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A callMethod() 0 13 4
1
<?php
2
namespace Holiday\Helper;
3
4
class HolidayHelper
5
{
6
    public static function callMethod($country, $method, $params)
7
    {
8
        $classNamePattern = 'Holiday\Country\%sHoliday';
9
        if (class_exists(sprintf($classNamePattern, $country))) {
10
            if (method_exists(sprintf($classNamePattern, $country), $method) && is_callable(sprintf($classNamePattern, $country), $method)) {
11
                return call_user_func_array(sprintf($classNamePattern.'::%s', $country, $method), $params);
12
            } else {
13
                throw new \BadMethodCallException(sprintf('The required method "%s" does not exist for %s', $method, sprintf($classNamePattern, $country)));
14
            }
15
        } else {
16
            throw new \InvalidArgumentException(sprintf('%s country does not exist.', $country));
17
        }
18
    }
19
}
20