DoormanRule::message()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Clarkeash\Doorman\Validation;
4
5
6
use Illuminate\Contracts\Validation\Rule;
7
8
class DoormanRule implements Rule
9
{
10
    /**
11
     * @var \Clarkeash\Doorman\Doorman
12
     */
13
    private $doorman;
14
15
    /**
16
     * @var string|null
17
     */
18
    private $email;
19
20 3
    public function __construct($email = null)
21
    {
22 3
        $this->doorman = app(\Clarkeash\Doorman\Doorman::class);
23 3
        $this->email = $email;
24 3
    }
25
26
    /**
27
     * Determine if the validation rule passes.
28
     *
29
     * @param  string $attribute
30
     * @param  mixed $value
31
     * @return bool
32
     */
33 3
    public function passes($attribute, $value)
34
    {
35 3
        return $this->doorman->check($value, $this->email);
36
    }
37
38
    /**
39
     * Get the validation error message.
40
     *
41
     * @return string|array
42
     */
43 1
    public function message()
44
    {
45 1
        return $this->doorman->error;
46
    }
47
}