DoormanRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 40
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

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