Completed
Pull Request — master (#17)
by Andres
02:32
created

Comfort   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 4
Bugs 0 Features 3
Metric Value
c 4
b 0
f 3
dl 0
loc 26
rs 10
wmc 5
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
B __call() 0 15 5
1
<?php
2
namespace Comfort;
3
4
use Comfort\Validator\ArrayValidator;
5
use Comfort\Validator\JsonValidator;
6
use Comfort\Validator\NumberValidator;
7
use Comfort\Validator\StringValidator;
8
9
/**
10
 * Class Comfort
11
 * @package Comfort
12
 * @method ArrayValidator array()
13
 * @method StringValidator string()
14
 * @method JsonValidator json()
15
 */
16
class Comfort
17
{
18
    /**
19
     * Returns validator for given data type
20
     *
21
     * @param $name
22
     * @param $arguments
23
     * @return ArrayValidator|JsonValidator|StringValidator
24
     * @throws \RuntimeException
25
     */
26
    public function __call($name, $arguments)
27
    {
28
        switch ($name) {
29
            case 'array':
30
                return new ArrayValidator($this);
31
            case 'string':
32
                return new StringValidator($this);
33
            case 'json':
34
                return new JsonValidator($this);
35
            case 'number':
36
                return new NumberValidator($this);
37
            default:
38
                throw new \RuntimeException('Unsupported data type');
39
        }
40
    }
41
}