ValidPascalCase::passes()   A
last analyzed

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 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Milwad\LaravelValidate\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class ValidPascalCase implements Rule
8
{
9
    /**
10
     * Check pascal-case is valid.
11
     */
12
    public function passes($attribute, $value): bool
13
    {
14
        return preg_match('/^[A-Z][a-z]+(?:[A-Z][a-z]+)*$/', $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match('/^[A-...-Z][a-z]+)*$/', $value) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
15
    }
16
17
    /**
18
     * Get the validation error message.
19
     */
20
    public function message(): string
21
    {
22
        return __('validate.pascal-case');
23
    }
24
}
25