Passed
Push — 1.x ( 1555de...6fec6a )
by Milwad
05:08 queued 01:46
created

ValidPascalCase   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 ValidPascalCase implements Rule
8
{
9
    /**
10
     * Check pascal-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('/^[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 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.pascal-case');
29
    }
30
}
31