Size   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 23
c 1
b 0
f 0
wmc 3
lcom 0
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 10 2
A getMessage() 0 4 1
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 Size extends BaseRule implements RuleInterface
17
{
18
    public function isValid()
19
    {
20
        if ($this->isNotRequiredAndEmpty()) {
21
            return true;
22
        }
23
24
        $value = trim($this->getParams()[1]);
25
26
        return mb_strlen($value) == $this->getParams()[2];
27
    }
28
29
    /**
30
     * Returns error message from rule.
31
     *
32
     * @return string
33
     */
34
    public function getMessage()
35
    {
36
        return 'Field :field: should has exact size :param:';
37
    }
38
}
39