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.

AbstractAppTest::evalValidation()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 3
eloc 11
nc 2
nop 1
1
<?php
2
3
namespace Tests;
4
5
use JsonSchema\Validator;
6
7
8
trait AbstractAppTest
9
{
10
    public function createApplication()
11
    {
12
        // print_r("DBG creao app");
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
13
        //$app = require_once __DIR__.'/../../src/App.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
14
        $config = require_once ROOT_PATH.'/config.php';
0 ignored issues
show
Unused Code introduced by
$config is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
15
        $app = require_once ROOT_PATH.'/src/App.php';
16
        $app['debug'] = true;
17
        $app['session.test'] = true;
18
        #unset($app['exception_handler']);
0 ignored issues
show
Unused Code Comprehensibility introduced by
100% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
19
        return $app;
20
    }
21
22
    public function logIn($client)
23
    {
24
        $client->request(
25
            'POST',
26
            '/api/v1/security/login',
27
            [],
28
            [],
29
            ['CONTENT_TYPE' => 'application/json'],
30
            '{"authMode":"Email","email":"[email protected]","name":"ugo","surname":"ugo","password":"cane"}');
31
        return $client;
32
    }
33
    public function logIn2($client)
34
    {
35
        $client->request(
36
            'POST',
37
            '/api/v1/security/login',
38
            [],
39
            [],
40
            ['CONTENT_TYPE' => 'application/json'],
41
            '{"authMode":"Email","email":"ugo2","name":"ugo2","surname":"ugo2","password":"cane"}');
42
        return $client;
43
    }
44
45
    /**
46
     * @param string $schema
47
     */
48
    public function askValidation($data, $schema)
49
    {
50
        $validator = new \JsonSchema\Validator;
51
        $js_schema = (object)['$ref' => 'file://'.$schema];
52
        $validator->check(json_decode($data), $js_schema);
53
        return $validator;
54
    }
55
56
    public function evalValidation($validator) {
57
        $assert = false;
0 ignored issues
show
Unused Code introduced by
$assert is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
58
        if ($validator->isValid()) {
59
            echo "The supplied JSON validates against the schema.\n";
60
            $assert = true;
61
        } else {
62
            echo "JSON does not validate. Violations:\n";
63
            foreach ($validator->getErrors() as $error) {
64
                echo "[{$error['property']}] {$error['message']}\n";
65
            }
66
            $assert = false;
67
        }
68
        return $assert;
69
    }
70
}
71