Passed
Push — master ( b2d39c...538fe0 )
by Stephen
01:06 queued 11s
created

ApplyWhen   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 3
b 0
f 0
dl 0
loc 15
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
1
<?php
2
3
namespace Monooso\Apposite\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class ApplyWhen extends ApplyMap implements Rule
8
{
9
    /**
10
     * Initialise the custom rule
11
     *
12
     * @param bool|callable $conditional
13
     * @param array|string  $rules
14
     */
15 5
    public function __construct($conditional, $rules)
16
    {
17 5
        $key = 'when';
18
19 5
        (bool)(is_callable($conditional) ? $conditional() : $conditional)
20 4
            ? parent::__construct($key, [$key => $rules])
21 1
            : parent::__construct($key, []);
22 5
    }
23
}
24