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

Comfort::__call()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 3
Metric Value
cc 5
eloc 12
c 4
b 0
f 3
nc 5
nop 2
dl 0
loc 15
rs 8.8571
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
}