Completed
Push — master ( bfd868...ee3a72 )
by Vincent
12:29 queued 10:26
created

assertIsValidAttributesObject()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 11
ccs 7
cts 7
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace VGirol\JsonApiAssert\Asserts;
3
4
use VGirol\JsonApiAssert\Messages;
5
6
trait AssertAttributesObject
7
{
8
    /**
9
     * Asserts that an attributes object is valid.
10
     *
11
     * @param array $attributes
12
     * 
13
     * @throws PHPUnit\Framework\ExpectationFailedException
14
     */
15 16
    public static function assertIsValidAttributesObject($attributes)
16
    {
17 16
        static::assertIsNotArrayOfObjects(
18 16
            $attributes,
19 16
            Messages::ATTRIBUTES_OBJECT_IS_NOT_ARRAY
20
        );
21
22 14
        static::assertFieldHasNoForbiddenMemberName($attributes);
23
24 13
        foreach ($attributes as $key => $value) {
25 13
            static::assertIsValidMemberName($key);
26
        }
27 11
    }
28
}
29