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

AirtableHandler   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 27
c 1
b 0
f 0
dl 0
loc 53
ccs 31
cts 31
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 13 2
A clearTable() 0 18 2
A createRows() 0 8 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
namespace BristolSU\ControlDB\Export\Handler\Airtable;
5
6
7
use BristolSU\ControlDB\Export\FormattedItem;
8
use BristolSU\ControlDB\Export\Handler\Handler;
9
use Carbon\Carbon;
10
use Illuminate\Support\Collection;
11
12
class AirtableHandler extends Handler
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class AirtableHandler
Loading history...
13
{
14
15
    /**
16
     * Save each item to AirTable
17
     * 
18
     * @param FormattedItem[] $items
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
19
     * @return mixed|void
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
20
     */
21 2
    protected function save(array $items)
22
    {
23 2
        $creating = [];
24
        
25 2
        foreach($items as $item) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
26 1
            $creating[] = [
27 1
                'fields' => $item->toArray()
28
            ];
29
        }
30
        
31 2
        $time = Carbon::now();
32 2
        $time = $this->clearTable($time);
33 2
        $this->createRows($creating, $time);
34 2
    }
35
36 2
    protected function createRows($creating, $time)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function createRows()
Loading history...
37
    {
38 2
        foreach (collect($creating)->chunk(10) as $fields) {
39 1
            dispatch(
40 1
                new CreateRows(['records' => $fields->values()->toArray(), 'typecast' => true], $this->config('apiKey'),
0 ignored issues
show
Bug introduced by
It seems like $this->config('apiKey') can also be of type null; however, parameter $apiKey of BristolSU\ControlDB\Expo...eateRows::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
                new CreateRows(['records' => $fields->values()->toArray(), 'typecast' => true], /** @scrutinizer ignore-type */ $this->config('apiKey'),
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
41 1
                    $this->config('baseId'), $this->config('tableName'))
0 ignored issues
show
Bug introduced by
It seems like $this->config('baseId') can also be of type null; however, parameter $baseId of BristolSU\ControlDB\Expo...eateRows::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

41
                    /** @scrutinizer ignore-type */ $this->config('baseId'), $this->config('tableName'))
Loading history...
Bug introduced by
It seems like $this->config('tableName') can also be of type null; however, parameter $tableName of BristolSU\ControlDB\Expo...eateRows::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

41
                    $this->config('baseId'), /** @scrutinizer ignore-type */ $this->config('tableName'))
Loading history...
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 16 spaces, but found 20.
Loading history...
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...
42 1
            )->delay($time);
43 1
            $time->addSeconds(2);
44
        }
45 2
    }
46
47 2
    protected function clearTable($time)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function clearTable()
Loading history...
48
    {
49 2
        $idRetriever = 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...
50 2
            'baseId' => $this->config('baseId'),
51 2
            'tableName' => $this->config('tableName')
52
        ]);
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...
53 2
        $ids = $idRetriever->ids();
54
55 2
        foreach ($ids->chunk(10) as $idsToRemove) {
56 1
            dispatch(
57 1
                new DeleteRows(['records' => $idsToRemove->values()->toArray()],
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...
58 1
                    $this->config('apiKey'), $this->config('baseId'),
0 ignored issues
show
Bug introduced by
It seems like $this->config('apiKey') can also be of type null; however, parameter $apiKey of BristolSU\ControlDB\Expo...leteRows::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
                    /** @scrutinizer ignore-type */ $this->config('apiKey'), $this->config('baseId'),
Loading history...
Bug introduced by
It seems like $this->config('baseId') can also be of type null; however, parameter $baseId of BristolSU\ControlDB\Expo...leteRows::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
                    $this->config('apiKey'), /** @scrutinizer ignore-type */ $this->config('baseId'),
Loading history...
59 1
                    $this->config('tableName'))
0 ignored issues
show
Bug introduced by
It seems like $this->config('tableName') can also be of type null; however, parameter $tableName of BristolSU\ControlDB\Expo...leteRows::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

59
                    /** @scrutinizer ignore-type */ $this->config('tableName'))
Loading history...
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 16 spaces, but found 20.
Loading history...
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...
60 1
            )->delay($time);
61 1
            $time->addSeconds(2);
62
        }
63 2
        $idRetriever->saveIds([]);
64 2
        return $time;
65
    }
66
67
68
}