Completed
Pull Request — master (#37)
by Anton
06:21
created

ValidatorConfig::resolveCondition()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
rs 9.6667
cc 3
eloc 4
nc 2
nop 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A ValidatorConfig::hasChecker() 0 4 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\Validation\Configs;
9
10
use Spiral\Core\InjectableConfig;
11
use Spiral\Core\Traits\Config\AliasTrait;
12
13
/**
14
 * Validation rules and checkers config.
15
 */
16
class ValidatorConfig extends InjectableConfig
17
{
18
    use AliasTrait;
19
20
    /**
21
     * Configuration section.
22
     */
23
    const CONFIG = 'validation';
24
25
    /**
26
     * @var array
27
     */
28
    protected $config = [
29
        'emptyConditions' => [],
30
        'checkers'        => [],
31
        'aliases'         => []
32
    ];
33
34
    /**
35
     * @param mixed $condition
36
     * @return bool
37
     */
38
    public function emptyCondition($condition)
39
    {
40
        return in_array($condition, $this->config['emptyConditions']);
41
    }
42
43
    /**
44
     * @param string $checker
45
     * @return bool
46
     */
47
    public function hasChecker($checker)
48
    {
49
        return isset($this->config['checkers'][$checker]);
50
    }
51
52
    /**
53
     * @param string $checker
54
     * @return string
55
     * @return string
56
     */
57
    public function checkerClass($checker)
58
    {
59
        return $this->config['checkers'][$checker];
60
    }
61
}