Completed
Pull Request — master (#37)
by Anton
09:20 queued 02:29
created

ValidatorConfig::emptyCondition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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
}