GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Symfony   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 66
ccs 18
cts 18
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A assertJsonMatchesSchema() 0 4 1
A assertJsonMatchesSchemaString() 0 4 1
A assertJsonValueEquals() 0 4 1
A assertJsonResponse() 0 12 1
1
<?php
2
3
/*
4
 * This file is part of the phpunit-json-assertions package.
5
 *
6
 * (c) Enrico Stahn <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace EnricoStahn\JsonAssert\Extension;
13
14
use EnricoStahn\JsonAssert\Assert;
15
use Symfony\Component\HttpFoundation\Response;
16
17
trait Symfony
18
{
19
    /**
20
     * Asserts that json content is valid according to the provided schema file.
21
     *
22
     * Example:
23
     *
24
     *   static::assertJsonMatchesSchema(json_decode('{"foo":1}'), './schema.json')
25
     *
26
     * @param string   $schema   Path to the schema file
27
     * @param Response $response JSON array or object
28
     */
29 1
    public static function assertJsonMatchesSchema($schema, Response $response)
30
    {
31 1
        Assert::assertJsonMatchesSchemaDepr($schema, json_decode($response->getContent()));
0 ignored issues
show
Deprecated Code introduced by
The method EnricoStahn\JsonAssert\A...JsonMatchesSchemaDepr() has been deprecated with message: This will be removed in the next major version (4.x).

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
32 1
    }
33
34
    /**
35
     * Asserts that json content is valid according to the provided schema string.
36
     *
37
     * @param string   $schema   Schema data
38
     * @param Response $response JSON content
39
     */
40 1
    public static function assertJsonMatchesSchemaString($schema, Response $response)
41
    {
42 1
        Assert::assertJsonMatchesSchemaString($schema, json_decode($response->getContent()));
43 1
    }
44
45
    /**
46
     * Asserts if the value retrieved with the expression equals the expected value.
47
     *
48
     * Example:
49
     *
50
     *     static::assertJsonValueEquals(33, 'foo.bar[0]', $json);
51
     *
52
     * @param mixed    $expected   Expected value
53
     * @param string   $expression Expression to retrieve the result
54
     *                             (e.g. locations[?state == 'WA'].name | sort(@))
55
     * @param Response $response   JSON Content
56
     */
57 1
    public static function assertJsonValueEquals($expected, $expression, $response)
58
    {
59 1
        Assert::assertJsonValueEquals($expected, $expression, json_decode($response->getContent()));
60 1
    }
61
62
    /**
63
     * Asserts that a response is successful and of type json.
64
     *
65
     * @param Response $response   Response object
66
     * @param int      $statusCode Expected status code (default 200)
67
     *
68
     * @see \Bazinga\Bundle\RestExtraBundle\Test\WebTestCase::assertJsonResponse()
69
     */
70 1
    public static function assertJsonResponse(Response $response, $statusCode = 200)
71
    {
72 1
        \PHPUnit\Framework\Assert::assertEquals(
73 1
            $statusCode,
74 1
            $response->getStatusCode(),
75 1
            $response->getContent()
76
        );
77 1
        \PHPUnit\Framework\Assert::assertTrue(
78 1
            $response->headers->contains('Content-Type', 'application/json'),
79 1
            $response->headers
80
        );
81 1
    }
82
}
83