Passed
Push — master ( 5153a0...c7b3db )
by Josh
03:56
created

NovaLensTest::novaLens()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace JoshGaber\NovaUnit\Lenses;
4
5
use Laravel\Nova\Lenses\Lens;
6
7
trait NovaLensTest
8
{
9
    /**
10
     * Initialize the Nova Action mock.
11
     *
12
     * @param string $lens The class path of the Lens
13
     * @param string $model The model used for making query assertions
14
     * @return MockLens The Lens mock instance
15
     * @throws InvalidNovaLensException If the supplied action class is not a Nova Lens
16
     */
17 2
    public static function novaLens(string $lens, string $model): MockLens
18
    {
19 2
        if (! \is_subclass_of($lens, Lens::class)) {
20 1
            throw new InvalidNovaLensException();
21
        }
22
23 1
        return new MockLens(new $lens(), $model);
24
    }
25
}
26