TwitterHandleRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A passes() 0 4 1
A message() 0 4 1
1
<?php
2
3
namespace BrunoFernandes\LaravelTwitterHandleValidation;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class TwitterHandleRule implements Rule
8
{
9
    /**
10
     * @var TwitterHandleValidator
11
     */
12
    protected $twitterHandleValidator;
13
14
    /**
15
     * @param TwitterHandleValidator $twitterHandleValidator
16
     */
17
    public function __construct(TwitterHandleValidator $twitterHandleValidator)
18
    {
19
        $this->twitterHandleValidator = $twitterHandleValidator;
20
    }
21
22
    /**
23
     * Determine if the validation rule passes.
24
     *
25
     * @param  string  $attribute
26
     * @param  mixed  $value
27
     * @return bool
28
     */
29
    public function passes($attribute, $value)
30
    {
31
        return $this->twitterHandleValidator->validate($attribute, $value);
32
    }
33
34
    /**
35
     * Get the validation error message.
36
     *
37
     * @return string
38
     */
39
    public function message()
40
    {
41
        return "The :attribute can only contain letters, numbers and ' _ '. Min 5 and max 15 characters.";
42
    }
43
}
44