Validator::setFactory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * @link https://github.com/phpviet/validation
4
 *
5
 * @copyright (c) PHP Viet
6
 * @license [MIT](https://opensource.org/licenses/MIT)
7
 */
8
9
namespace PHPViet\Validation;
10
11
use Respect\Validation\Factory;
12
use Respect\Validation\Validator as BaseValidator;
13
14
/**
15
 * @method static Validator landLineVN()
16
 * @method static Validator mobileVN()
17
 * @method static Validator ipVN(?int $version = null)
18
 * @method static Validator idVN()
19
 *
20
 * @author Vuong Minh <[email protected]>
21
 * @since 1.0.0
22
 */
23
class Validator extends BaseValidator
24
{
25
    /**
26
     * @return Factory
27
     */
28
    protected static function getFactory()
29
    {
30
        if (! static::$factory instanceof Factory) {
31
            $factory = static::$factory = new Factory();
32
            $factory->prependRulePrefix('\\PHPViet\\Validation\\Rules\\');
33
        }
34
35
        return static::$factory;
36
    }
37
38
    /**
39
     * @param Factory $factory
40
     */
41
    public static function setFactory($factory)
42
    {
43
        $factory->prependRulePrefix('\\PHPViet\\Validation\\Rules\\');
44
45
        static::$factory = $factory;
46
    }
47
}
48