bristol-su /
airtable
| 1 | <?php |
||
| 2 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 3 | namespace BristolSU\AirTable\Jobs; |
||
| 4 | |||
| 5 | use BristolSU\AirTable\AirTable; |
||
| 6 | use Illuminate\Bus\Queueable; |
||
| 7 | use Illuminate\Contracts\Queue\ShouldQueue; |
||
| 8 | use Illuminate\Foundation\Bus\Dispatchable; |
||
| 9 | use Illuminate\Support\Facades\Log; |
||
| 10 | |||
| 11 | class FlushRows implements ShouldQueue |
||
|
0 ignored issues
–
show
|
|||
| 12 | { |
||
| 13 | use Dispatchable, Queueable; |
||
| 14 | |||
| 15 | private string $apiKey; |
||
|
0 ignored issues
–
show
|
|||
| 16 | |||
| 17 | private string $baseId; |
||
|
0 ignored issues
–
show
|
|||
| 18 | |||
| 19 | private string $tableName; |
||
|
0 ignored issues
–
show
|
|||
| 20 | |||
| 21 | private bool $debug = false; |
||
|
0 ignored issues
–
show
|
|||
| 22 | |||
| 23 | 5 | public function __construct(string $apiKey, string $baseId, string $tableName) |
|
|
0 ignored issues
–
show
|
|||
| 24 | { |
||
| 25 | 5 | $this->apiKey = $apiKey; |
|
| 26 | 5 | $this->baseId = $baseId; |
|
| 27 | 5 | $this->tableName = $tableName; |
|
| 28 | 5 | } |
|
| 29 | |||
| 30 | 1 | public function handle(AirTable $airTable) |
|
|
0 ignored issues
–
show
|
|||
| 31 | { |
||
| 32 | 1 | $airTable->setApiKey($this->apiKey); |
|
| 33 | 1 | $airTable->setBaseId($this->baseId); |
|
| 34 | 1 | $airTable->setTableName($this->tableName); |
|
| 35 | 1 | $this->log('Retrieving IDs'); |
|
| 36 | 1 | $ids = $airTable->getIdsFromTable(); |
|
| 37 | 1 | $this->log('Retrieved IDs'); |
|
| 38 | 1 | $this->log('Deleting Rows'); |
|
| 39 | 1 | foreach(array_chunk($ids, 50) as $idsToDelete) { |
|
|
0 ignored issues
–
show
|
|||
| 40 | 1 | dispatch((new DeleteRows( |
|
|
0 ignored issues
–
show
|
|||
| 41 | 1 | $idsToDelete, |
|
| 42 | 1 | $this->apiKey, |
|
| 43 | 1 | $this->baseId, |
|
| 44 | 1 | $this->tableName) |
|
|
0 ignored issues
–
show
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...
|
|||
| 45 | 1 | )->withDebug($this->debug)); |
|
|
0 ignored issues
–
show
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...
|
|||
| 46 | } |
||
| 47 | 1 | } |
|
| 48 | |||
| 49 | 4 | public function withDebug(bool $debug) |
|
|
0 ignored issues
–
show
|
|||
| 50 | { |
||
| 51 | 4 | $this->debug = $debug; |
|
| 52 | 4 | return $this; |
|
| 53 | } |
||
| 54 | |||
| 55 | 1 | private function log(string $string) |
|
|
0 ignored issues
–
show
|
|||
| 56 | { |
||
| 57 | 1 | if($this->debug) { |
|
|
0 ignored issues
–
show
|
|||
| 58 | Log::debug($string); |
||
| 59 | } |
||
| 60 | } |
||
| 61 | } |