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.
Completed
Push — rewrite-laravel ( 96dff9...f203d9 )
by Oliver
11:47
created

AbstractApiTestCase   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 46.15 %

Coupling/Cohesion

Components 3
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 3
cbo 3
dl 36
loc 78
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A buildUrl() 0 7 1
A seeSuccess() 0 5 1
A seeIsNotSoftDeletedInDatabase() 18 18 2
A seeIsSoftDeletedInDatabase() 18 18 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: okaufmann
5
 * Date: 28.10.2016
6
 * Time: 01:23.
7
 */
8
namespace App\Tests\Api;
9
10
use App\Tests\AbstractTestCase;
11
use Illuminate\Foundation\Testing\DatabaseMigrations;
12
13
abstract class AbstractApiTestCase extends AbstractTestCase
14
{
15
    use DatabaseMigrations;
16
17
    protected $apiUri = '/services.php';
18
    protected $guid = '{D6A33C24-DE43-D62C-A609-EF5138F33F30}';
19
    protected $success = 'Operation has succeeded';
20
21
    protected function buildUrl(string $url, array $data) : string
0 ignored issues
show
Unused Code introduced by
The parameter $url is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $data['guid'] = $this->guid;
24
        $paramString = http_build_query($data);
25
26
        return $this->apiUri.'?'.$paramString;
27
    }
28
29
    protected function seeSuccess()
30
    {
31
        return $this->seeStatusCode(200)
32
            ->see($this->success);
33
    }
34
35
    /**
36
     * Assert that a given where condition does not matches a soft deleted record
37
     * From: http://stackoverflow.com/questions/33117746/laravel-unit-testing-how-to-seeindatabase-soft-deleted-row
38
     *
39
     * @param  string $table
40
     * @param  array $data
41
     * @param  string $connection
42
     * @return $this
43
     */
44 View Code Duplication
    protected function seeIsNotSoftDeletedInDatabase($table, array $data, $connection = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        $database = $this->app->make('db');
47
48
        $connection = $connection ?: $database->getDefaultConnection();
49
50
        $count = $database->connection($connection)
51
            ->table($table)
52
            ->where($data)
53
            ->whereNull('deleted_at')
54
            ->count();
55
56
        $this->assertGreaterThan(0, $count, sprintf(
57
            'Found unexpected records in database table [%s] that matched attributes [%s].', $table, json_encode($data)
58
        ));
59
60
        return $this;
61
    }
62
63
    /**
64
     * Assert that a given where condition matches a soft deleted record
65
     * From: http://stackoverflow.com/questions/33117746/laravel-unit-testing-how-to-seeindatabase-soft-deleted-row
66
     *
67
     * @param  string $table
68
     * @param  array $data
69
     * @param  string $connection
70
     * @return $this
71
     */
72 View Code Duplication
    protected function seeIsSoftDeletedInDatabase($table, array $data, $connection = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
    {
74
        $database = $this->app->make('db');
75
76
        $connection = $connection ?: $database->getDefaultConnection();
77
78
        $count = $database->connection($connection)
79
            ->table($table)
80
            ->where($data)
81
            ->whereNotNull('deleted_at')
82
            ->count();
83
84
        $this->assertGreaterThan(0, $count, sprintf(
85
            'Found unexpected records in database table [%s] that matched attributes [%s].', $table, json_encode($data)
86
        ));
87
88
        return $this;
89
    }
90
}
91