ThingExists::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class ThingExists implements Rule
8
{
9
    protected $item;
10
11
    /**
12
     * Create a new rule instance.
13
     *
14
     * @param $item
15
     */
16
    public function __construct($item = null)
17
    {
18
        $this->item = $item;
19
    }
20
21
    /**
22
     * Determine if the validation rule passes.
23
     *
24
     * @param  string  $attribute
25
     * @param  mixed  $value
26
     * @return bool
27
     */
28
    public function passes($attribute, $value)
29
    {
30
        return !is_null($this->item);
31
    }
32
33
    /**
34
     * Get the validation error message.
35
     *
36
     * @return string
37
     */
38
    public function message()
39
    {
40
        return 'Tingen ble ikke funnet! Kanskje du ser etter tingen i seg selv?';
41
    }
42
}
43