Passed
Push — master ( e32a81...12baf4 )
by Antonio Carlos
02:26
created

CloudStorage::check()   A

Complexity

Conditions 3
Paths 7

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3.3332

Importance

Changes 0
Metric Value
cc 3
nc 7
nop 0
dl 0
loc 28
ccs 10
cts 15
cp 0.6667
crap 3.3332
rs 9.472
c 0
b 0
f 0
1
<?php
2
3
namespace PragmaRX\Health\Checkers;
4
5
use PragmaRX\Health\Support\Result;
6
use Illuminate\Support\Facades\Storage;
7
8
class CloudStorage extends Base
9
{
10
    /**
11
     * @return Result
12
     */
13 1
    public function check()
14
    {
15
        try {
16 1
            Storage::disk($this->target->driver)->put(
0 ignored issues
show
Bug introduced by
The property driver does not seem to exist in PragmaRX\Health\Support\Target.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
17 1
                $this->target->file,
0 ignored issues
show
Bug introduced by
The property file does not seem to exist in PragmaRX\Health\Support\Target.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
18 1
                $this->target->contents
0 ignored issues
show
Bug introduced by
The property contents does not seem to exist in PragmaRX\Health\Support\Target.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
19
            );
20
21 1
            $contents = Storage::disk($this->target->driver)->get(
22 1
                $this->target->file
23
            );
24
25 1
            Storage::disk($this->target->driver)->delete($this->target->file);
26
27 1
            if ($contents !== $this->target->contents) {
28
                return $this->makeResult(
29
                    false,
30
                    $this->target->getErrorMessage()
31
                );
32
            }
33
34 1
            return $this->makeHealthyResult();
35 1
        } catch (\Exception $exception) {
36
            report($exception);
37
38
            return $this->makeResultFromException($exception);
39
        }
40
    }
41
}
42