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

HasValidFields   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toString() 0 3 1
A matches() 0 13 4
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