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

HasValidFields::toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace JoshGaber\NovaUnit\Constraints;
4
5
use Laravel\Nova\Fields\Field;
6
use PHPUnit\Framework\Constraint\Constraint;
7
8
class HasValidFields extends Constraint
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 4
    public function toString(): string
14
    {
15 4
        return 'contains valid fields only';
16
    }
17
18 6
    public function matches($other): bool
19
    {
20 6
        if (! \is_array($other)) {
21 2
            return false;
22
        }
23
24 4
        foreach ($other as $field) {
25 4
            if (! $field instanceof Field) {
26 4
                return false;
27
            }
28
        }
29
30 2
        return true;
31
    }
32
}
33