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

ValidCamelCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A passes() 0 3 1
A message() 0 3 1
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
}