Passed
Push — 1.x ( 759dd0...48e27e )
by Milwad
01:05 queued 13s
created

ValidCamelCase::passes()   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 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 ValidCamelCase implements Rule
8
{
9
    /**
10
     * Check value is camel case.
11
     *
12
     * @param  string  $attribute
13
     * @param  mixed  $value
14
     * @return bool
15
     */
16
    public function passes($attribute, $value)
17
    {
18
        return preg_match('/^(?:\p{Lu}?\p{Ll}+)(?:\p{Lu}\p{Ll}+)*$/u', $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match('/^(?:...}\p{Ll}+)*$/u', $value) returns the type integer which is incompatible with the documented return type boolean.
Loading history...
19
    }
20
21
    /**
22
     * Get the validation error message.
23
     *
24
     * @return string
25
     */
26
    public function message()
27
    {
28
        return __('validate.camel-case');
29
    }
30
}