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.
Passed
Push — master ( c07b11...b289ea )
by Toby
27:25 queued 11s
created

CreateRows   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 22
c 1
b 0
f 0
dl 0
loc 50
ccs 17
cts 17
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 21 2
A __construct() 0 6 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Export\Handler\Airtable;
4
5
use BristolSU\ControlDB\Export\FormattedItem;
6
use GuzzleHttp\Client;
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Contracts\Queue\ShouldQueue;
9
use Illuminate\Foundation\Events\Dispatchable;
10
use Illuminate\Support\Collection;
11
12
class CreateRows implements ShouldQueue
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class CreateRows
Loading history...
13
{
14
    use Dispatchable, Queueable;
15
16
    private array $data;
0 ignored issues
show
Coding Style introduced by
Private member variable "data" must be prefixed with an underscore
Loading history...
17
    private string $apiKey;
0 ignored issues
show
Coding Style introduced by
Private member variable "apiKey" must be prefixed with an underscore
Loading history...
18
    private string $baseId;
0 ignored issues
show
Coding Style introduced by
Private member variable "baseId" must be prefixed with an underscore
Loading history...
19
    private string $tableName;
0 ignored issues
show
Coding Style introduced by
Private member variable "tableName" must be prefixed with an underscore
Loading history...
20
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
     * @var Collection
22
     */
23
    private Collection $creatingItems;
0 ignored issues
show
introduced by
The private property $creatingItems is not used, and could be removed.
Loading history...
Coding Style introduced by
Private member variable "creatingItems" must be prefixed with an underscore
Loading history...
24
25
    /**
26
     * CreateRows constructor.
27
     * @param array $data
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 22 spaces after parameter type; 1 found
Loading history...
28
     * @param string $apiKey
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 21 spaces after parameter type; 1 found
Loading history...
29
     * @param string $baseId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 21 spaces after parameter type; 1 found
Loading history...
30
     * @param string $tableName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 21 spaces after parameter type; 1 found
Loading history...
31
     * @param Collection|FormattedItem[] $creatingItems
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Superfluous parameter comment
Loading history...
32
     */
33 3
    public function __construct(array $data, string $apiKey, string $baseId, string $tableName)
34
    {
35 3
        $this->data = $data;
36 3
        $this->apiKey = $apiKey;
37 3
        $this->baseId = $baseId;
38 3
        $this->tableName = $tableName;
39 3
    }
40
41 2
    public function handle(Client $client)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function handle()
Loading history...
42
    {
43 2
        $response = $client->post(
44 2
            sprintf('https://api.airtable.com/v0/%s/%s', $this->baseId, $this->tableName),
45
            [
46 2
                'json' => $this->data,
47
                'headers' => [
48 2
                    'Authorization' => 'Bearer ' . $this->apiKey
49
                ]
50
            ]
51
        );
52
        
53
        /** @var IdRetriever $idRetriver */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
54 2
        $idRetriver = app(IdRetriever::class, [
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
55 2
            'baseId' => $this->baseId,
56 2
            'tableName' => $this->tableName
57
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
58
        
59 2
        $records = json_decode($response->getBody()->getContents(), true);
60 2
        foreach($records['records'] as $record) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
61 2
            $idRetriver->pushId($record['id']);
62
        }
63 2
    }
64
65
}