| Conditions | 3 |
| Paths | 4 |
| Total Lines | 31 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | 1 | protected function save(array $items) |
|
| 23 | { |
||
| 24 | 1 | $creating = []; |
|
| 25 | |||
| 26 | 1 | foreach($items as $item) { |
|
| 27 | 1 | $creating[] = $item->toArray(); |
|
| 28 | } |
||
| 29 | |||
| 30 | 1 | $this->log('Flushing rows'); |
|
| 31 | |||
| 32 | 1 | dispatch_now( |
|
| 33 | 1 | (new FlushRows( |
|
| 34 | 1 | $this->config('apiKey'), |
|
| 35 | 1 | $this->config('baseId'), |
|
| 36 | 1 | $this->config('tableName') |
|
| 37 | 1 | ))->withDebug($this->config('debug', false)) |
|
| 38 | ); |
||
| 39 | |||
| 40 | 1 | $this->log('Flushed rows. Creating records'); |
|
| 41 | |||
| 42 | |||
| 43 | 1 | foreach(array_chunk($creating, 10) as $data) { |
|
| 44 | 1 | dispatch((new CreateRecords( |
|
| 45 | 1 | $data, |
|
| 46 | 1 | $this->config('apiKey'), |
|
| 47 | 1 | $this->config('baseId'), |
|
| 48 | 1 | $this->config('tableName') |
|
| 49 | 1 | ))->withDebug($this->config('debug', false))); |
|
| 50 | } |
||
| 51 | |||
| 52 | 1 | $this->log('Created Records'); |
|
| 53 | |||
| 63 |