| Conditions | 4 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 |