AssertJsonapi   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A assertJsonapiObjectEquals() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiAssert\Asserts\Content;
6
7
use PHPUnit\Framework\Assert as PHPUnit;
8
use VGirol\JsonApiAssert\Messages;
9
10
/**
11
 * This trait adds the ability to test jsonapi object content.
12
 */
13
trait AssertJsonapi
14
{
15
    /**
16
     * Asserts that a jsonapi object equals an expected array.
17
     *
18
     * @link https://jsonapi.org/format/#document-jsonapi-object
19
     *
20
     * @param array $expected The expected jsonapi object
21
     * @param array $json     The jsonapi object to test
22
     *
23
     * @return void
24
     * @throws \PHPUnit\Framework\AssertionFailedError
25
     */
26 6
    public static function assertJsonapiObjectEquals($expected, $json): void
27
    {
28 6
        PHPUnit::assertSame(
29 6
            $expected,
30 6
            $json,
31 6
            sprintf(Messages::JSONAPI_OBJECT_NOT_EQUAL, var_export($json, true), var_export($expected, true))
32
        );
33 3
    }
34
}
35