NovaActionTest::novaAction()   A
last analyzed

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 1
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\Actions;
4
5
use Laravel\Nova\Actions\Action;
6
7
trait NovaActionTest
8
{
9
    /**
10
     * Initialize the Nova Action mock.
11
     *
12
     * @param string $action The class path of the Action
13
     * @return MockAction The Action mock instance
14
     * @throws InvalidNovaActionException If the supplied action class is not a Nova Action
15
     */
16 2
    public static function novaAction(string $action): MockAction
17
    {
18 2
        if (! \is_subclass_of($action, Action::class)) {
19 1
            throw new InvalidNovaActionException('The class provided is not a valid Nova Action.');
20
        }
21
22 1
        return new MockAction(new $action());
23
    }
24
}
25