Passed
Pull Request — 1.x (#109)
by
unknown
04:09
created

ValidIranPlate   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A message() 0 3 1
A passes() 0 3 1
1
<?php
2
3
namespace Milwad\LaravelValidate\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class ValidIranPlate implements Rule
8
{
9
    /**
10
     * Check License Plate Validator.
11
     */
12
    public function passes($attribute, $value): bool
13
    {
14
        return preg_match("/^\d{2}\s?[آ-ی]\s?\d{3}\s?ایران\s?\d{2}$/u", $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match('/^\d{...ن\s?\d{2}$/u', $value) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
15
    }
16
17
    /**
18
     * Get the License Plate Validator error message.
19
     */
20
    public function message(): string
21
    {
22
        return __('validate.iran-plate');
23
    }
24
}
25