ValidatorFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 18
c 1
b 0
f 0
dl 0
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A loadTranslator() 0 21 1
A __call() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
namespace AkkiIo\CronExpressionGenerator;
4
5
use Illuminate\Filesystem\Filesystem;
6
use Illuminate\Translation;
7
use Illuminate\Translation\FileLoader;
8
use Illuminate\Translation\Translator;
9
use Illuminate\Validation\Factory;
10
11
class ValidatorFactory
12
{
13
    /**
14
     * @var Factory
15
     */
16
    private Factory $factory;
17
18
    /**
19
     * ValidatorFactory constructor.
20
     */
21
    public function __construct()
22
    {
23
        $this->factory = new Factory($this->loadTranslator());
24
    }
25
26
    /**
27
     * Load the translator from the lang file.
28
     *
29
     * @return Translation\Translator
30
     */
31
    protected function loadTranslator()
32
    {
33
        $fileSystem = new Filesystem();
34
35
        $loader = new FileLoader(
36
            $fileSystem,
37
            dirname(dirname(__FILE__)).'/lang'
38
        );
39
40
        $loader->addNamespace(
41
            'lang',
42
            dirname(dirname(__FILE__)).'/lang'
43
        );
44
45
        $loader->load(
46
            'en',
47
            'validation',
48
            'lang'
49
        );
50
51
        return new Translator($loader, 'en');
52
    }
53
54
    /**
55
     * Magic call method.
56
     *
57
     * @param $method
58
     * @param $args
59
     * @return false|mixed
60
     */
61
    public function __call($method, $args)
62
    {
63
        return call_user_func_array(
64
            [$this->factory, $method],
65
            $args
66
        );
67
    }
68
}
69