ValidatesPredicates::isPredicate()   A
last analyzed

Complexity

Conditions 6
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 9
nc 3
nop 1
dl 0
loc 16
ccs 9
cts 9
cp 1
crap 6
rs 9.2222
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\FluentAQL\Traits;
6
7
use LaravelFreelancerNL\FluentAQL\Expressions\PredicateExpression;
8
9
trait ValidatesPredicates
10
{
11 4
    public function isPredicate(mixed $value): bool
12
    {
13 4
        if ($value instanceof PredicateExpression) {
14 4
            return true;
15
        }
16
17
        if (
18 4
            is_array($value)
19 4
            && isset($value[0])
20 4
            && ! is_array($value[0])
21 4
            && ! $value[0] instanceof PredicateExpression
22
        ) {
23 4
            return true;
24
        }
25
26 4
        return false;
27
    }
28
}
29