IranMobile::rule()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 3
c 1
b 0
f 1
nc 2
nop 4
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Iamfarhad\Validation\Rules;
4
5
use Iamfarhad\Validation\Contracts\AbstractValidationRule;
6
7
class IranMobile extends AbstractValidationRule
8
{
9
    /**
10
     * @var string
11
     */
12
    public $validationRule = 'iran_mobile';
13
14
    /**
15
     * @param $attribute
16
     * @param $value
17
     * @param $parameters
18
     * @param $validator
19
     * @return bool
20
     */
21
    public function rule($attribute, $value, $parameters, $validator): bool
22
    {
23
        if ((bool) preg_match('/^(((98)|(\+98)|(0098)|0)(9){1}[0-9]{9})+$/', $value) || (bool) preg_match('/^(9){1}[0-9]{9}+$/', $value)) {
24
            return true;
25
        }
26
27
        return false;
28
    }
29
}
30