Completed
Push — master ( a12164...2a5888 )
by Arman
16s queued 12s
created

Length::exactLen()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.9.8
13
 */
14
15
namespace Quantum\Libraries\Validation\Traits;
16
17
/**
18
 * Trait Length
19
 * @package Quantum\Libraries\Validation\Rules
20
 */
21
trait Length
22
{
23
24
    /**
25
     * Checks the min Length
26
     * @param string $field
27
     * @param string $value
28
     * @param int $minLength
29
     * @return bool
30
     */
31
    protected function minLen(string $field, string $value, int $minLength): bool
0 ignored issues
show
Unused Code introduced by
The parameter $field is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

31
    protected function minLen(/** @scrutinizer ignore-unused */ string $field, string $value, int $minLength): bool

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
        return mb_strlen($value) >= $minLength;
34
    }
35
36
    /**
37
     * Checks the max Length
38
     * @param string $field
39
     * @param string $value
40
     * @param int $maxLength
41
     * @return bool
42
     */
43
    protected function maxLen(string $field, string $value, int $maxLength): bool
0 ignored issues
show
Unused Code introduced by
The parameter $field is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

43
    protected function maxLen(/** @scrutinizer ignore-unused */ string $field, string $value, int $maxLength): bool

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
        return mb_strlen($value) <= $maxLength;
46
    }
47
48
    /**
49
     * Checks the exact length
50
     * @param string $field
51
     * @param string $value
52
     * @param int $exactLength
53
     * @return bool
54
     */
55
    protected function exactLen(string $field, string $value, int $exactLength): bool
0 ignored issues
show
Unused Code introduced by
The parameter $field is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

55
    protected function exactLen(/** @scrutinizer ignore-unused */ string $field, string $value, int $exactLength): bool

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
56
    {
57
        return mb_strlen($value) === $exactLength;
58
    }
59
}