TwitterHandleRule::message()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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