AssertArrays::assertIsArrayOfObjects()   A
last analyzed

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiAssert\Asserts\Structure;
6
7
/**
8
 * Assertions relating to the arrays
9
 */
10
trait AssertArrays
11
{
12
    /**
13
     * Asserts that an array is an array of objects.
14
     *
15
     * @param array  $json
16
     * @param string $message An optional message to explain why the test failed
17
     *
18
     * @return void
19
     * @throws \PHPUnit\Framework\AssertionFailedError
20
     */
21 48
    public static function assertIsArrayOfObjects($json, $message = ''): void
22
    {
23 48
        static::askService('mustBeArrayOfObjects', $json, $message);
24 33
    }
25
26
    /**
27
     * Asserts that an array is not an array of objects.
28
     *
29
     * @param array  $json
30
     * @param string $message An optional message to explain why the test failed
31
     *
32
     * @return void
33
     * @throws \PHPUnit\Framework\AssertionFailedError
34
     */
35 18
    public static function assertIsNotArrayOfObjects($json, $message = ''): void
36
    {
37 18
        static::askService('mustNotBeArrayOfObjects', $json, $message);
38 9
    }
39
40
    /**
41
     * Checks if the given array is an array of objects.
42
     *
43
     * @param array $arr
44
     *
45
     * @return boolean
46
     */
47 39
    protected static function isArrayOfObjects(array $arr): bool
48
    {
49 39
        return static::proxyService('isArrayOfObjects', $arr);
50
    }
51
}
52