NeverLoanedOut   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A passes() 0 3 1
A message() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
namespace App\Rules;
4
5
use App\Item;
6
use Illuminate\Contracts\Validation\Rule;
7
use function Stringy\create as s;
8
9
class NeverLoanedOut implements Rule
10
{
11
    protected $item;
12
13
    /**
14
     * Create a new rule instance.
15
     *
16
     * @param Item $item
17
     */
18
    public function __construct(Item $item)
19
    {
20
        $this->item = $item;
21
    }
22
23
    /**
24
     * Determine if the validation rule passes.
25
     *
26
     * @param  string  $attribute
27
     * @param  mixed  $value
28
     * @return bool
29
     */
30
    public function passes($attribute, $value)
31
    {
32
        return false;
33
    }
34
35
    /**
36
     * Get the validation error message.
37
     *
38
     * @return string
39
     */
40
    public function message()
41
    {
42
        return sprintf(
43
            '%s har egentlig aldri vært utlånt så vidt Bibrex kan se.',
44
            s($this->item->thing->properties->get('name_definite.nob'))->upperCaseFirst()
45
        );
46
    }
47
}
48