Same::getMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * @author: Abdul Qureshi. <[email protected]>
5
 * 
6
 * This file has been modified from the original source.
7
 * See original here:
8
 *
9
 * @link: https://github.com/progsmile/request-validator
10
 */
11
12
namespace TheSupportGroup\Common\Validator\Rules;
13
14
use TheSupportGroup\Common\Validator\Contracts\Rules\RuleInterface;
15
16
class Same extends BaseRule implements RuleInterface
17
{
18
    public function isValid()
19
    {
20
        $data = $this->getConfig(BaseRule::CONFIG_DATA);
21
22
        $input = $this->getParams()[1];
23
        $value = $this->getParams()[2];
24
25
        if (!isset($data[$value])) {
26
            return false;
27
        }
28
29
        return $this->Equals($data[$value])->validate($input);
0 ignored issues
show
Documentation Bug introduced by
The method Equals does not exist on object<TheSupportGroup\C...n\Validator\Rules\Same>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
30
    }
31
32
    public function getMessage()
33
    {
34
        return 'Field :field: should have same value with :rule: field';
35
    }
36
}
37