Code Duplication    Length = 36-38 lines in 2 locations

src/Libraries/MultiValues/RuleMapping.php 1 location

@@ 16-53 (lines=38) @@
13
use PluginSimpleValidate\Exception\RuleNotExist;
14
use PluginSimpleValidate\WithValue\Rule;
15
16
class RuleMapping extends \PluginSimpleValidate\BaseAbstract\RuleMapping implements RuleMappingWithValue
17
{
18
    /**
19
     * @var $this
20
     */
21
    private static $instance;
22
23
    /**
24
     * @return \PluginSimpleValidate\Contracts\RuleMappingWithValue
25
     */
26
    public static function getInstance()
27
    {
28
        if (is_null(static::$instance)) {
29
            static::$instance = new self();
30
        }
31
32
        return static::$instance;
33
    }
34
35
    /**
36
     * @param string $key
37
     * @param mixed $value
38
     * @param array $args
39
     * @return ContractsRuleWithValue
40
     * @throws RuleNotExist
41
     */
42
    public function getRule(string $key, $value, array $args = []): ContractsRuleWithValue
43
    {
44
        $this->checkRule($key);
45
46
        return new Rule(
47
            $this->list[$key]['validation_method'],
48
            $this->list[$key]['lang_key'],
49
            $value,
50
            $args
51
        );
52
    }
53
}

src/Libraries/RuleMapping.php 1 location

@@ 15-50 (lines=36) @@
12
use PluginSimpleValidate\Exception\RuleNotExist;
13
use PluginSimpleValidate\Rule;
14
15
class RuleMapping extends \PluginSimpleValidate\BaseAbstract\RuleMapping implements \PluginSimpleValidate\Contracts\RuleMapping
16
{
17
    /**
18
     * @var $this
19
     */
20
    private static $instance;
21
22
    /**
23
     * @return \PluginSimpleValidate\Contracts\RuleMapping
24
     */
25
    public static function getInstance()
26
    {
27
        if (is_null(static::$instance)) {
28
            static::$instance = new self();
29
        }
30
31
        return static::$instance;
32
    }
33
34
    /**
35
     * @param string $key
36
     * @param array $args
37
     * @return ContractsRule
38
     * @throws RuleNotExist
39
     */
40
    public function getRule(string $key, array $args = []): ContractsRule
41
    {
42
        $this->checkRule($key);
43
44
        return new Rule(
45
            $this->list[$key]['validation_method'],
46
            $this->list[$key]['lang_key'],
47
            $args
48
        );
49
    }
50
}