| Conditions | 4 |
| Paths | 11 |
| Total Lines | 31 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function call() |
||
| 15 | { |
||
| 16 | $builder = $this->getBuilder(); |
||
| 17 | |||
| 18 | $name = $this->getParam('name'); |
||
| 19 | $file = $this->getParam('file', '/health.txt'); |
||
| 20 | |||
| 21 | $contents = $this->getParam('contents', random_bytes(32)); |
||
| 22 | $options = $this->getParam('options', []); |
||
| 23 | |||
| 24 | try { |
||
| 25 | StorageFacade::disk($name)->put($file, $contents, $options); |
||
| 26 | |||
| 27 | $fileContents = StorageFacade::disk($name)->get($file); |
||
| 28 | |||
| 29 | if ($contents !== $fileContents) { |
||
| 30 | $builder->down()->withData('error', 'Contents mismatch'); |
||
| 31 | } |
||
| 32 | |||
| 33 | if (! StorageFacade::disk($name)->delete($file)) { |
||
| 34 | $builder->down()->withData('error', 'Could not delete file'); |
||
| 35 | } |
||
| 36 | } catch (\Exception $exception) { |
||
| 37 | $builder->down()->withData('error', $exception->getMessage()); |
||
| 38 | } |
||
| 39 | |||
| 40 | $builder->withData('name', $name) |
||
| 41 | ->withData('file', $file) |
||
| 42 | ->withData('contents', $contents); |
||
| 43 | |||
| 44 | return $builder->build(); |
||
| 45 | } |
||
| 47 |