These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace PragmaRX\Health\Checkers; |
||
4 | |||
5 | use Illuminate\Support\Facades\DB; |
||
6 | use PragmaRX\Health\Support\Timer; |
||
7 | use PragmaRX\Health\Support\Result; |
||
8 | |||
9 | class Database extends Base |
||
10 | { |
||
11 | /** |
||
12 | * @return Result |
||
13 | */ |
||
14 | 1 | public function check() |
|
15 | { |
||
16 | try { |
||
17 | 1 | switch ($this->target->type) { |
|
0 ignored issues
–
show
|
|||
18 | case 'find_first_model': |
||
19 | 1 | return $this->findFirstModel(); |
|
20 | case 'raw_query': |
||
21 | 1 | return $this->rawQuery(); |
|
22 | } |
||
23 | |||
24 | throw new \Exception( |
||
25 | "Target type '{$this->target->type}' does not exists" |
||
26 | ); |
||
27 | 1 | } catch (\Exception $exception) { |
|
28 | 1 | report($exception); |
|
29 | |||
30 | 1 | return $this->makeResultFromException($exception); |
|
31 | } |
||
32 | } |
||
33 | |||
34 | 1 | protected function findFirstModel() |
|
35 | { |
||
36 | collect($this->target->models)->each(function ($model) { |
||
0 ignored issues
–
show
The property
models 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...
|
|||
37 | 1 | instantiate($model)->first(); |
|
38 | 1 | }); |
|
39 | |||
40 | return $this->makeHealthyResult(); |
||
41 | } |
||
42 | |||
43 | 1 | protected function getConnectionName() |
|
44 | { |
||
45 | 1 | return $this->target->connection == 'default' |
|
0 ignored issues
–
show
The property
connection 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...
|
|||
46 | 1 | ? config('database.default') |
|
47 | 1 | : $this->target->connection; |
|
48 | } |
||
49 | |||
50 | 1 | protected function rawQuery() |
|
51 | { |
||
52 | 1 | Timer::start(); |
|
53 | |||
54 | 1 | DB::connection($this->getConnectionName())->select( |
|
55 | 1 | DB::raw($this->target->query) |
|
0 ignored issues
–
show
The property
query 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...
|
|||
56 | ); |
||
57 | |||
58 | $took = round(Timer::stop(), 5); |
||
59 | $tookHuman = "{$took}s"; |
||
60 | |||
61 | $this->target->setDisplay($this->target->name." ({$tookHuman})"); |
||
62 | |||
63 | $result = |
||
64 | $took > $this->target->maximumTime |
||
0 ignored issues
–
show
The property
maximumTime 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...
|
|||
65 | ? $this->makeResult( |
||
66 | false, |
||
67 | sprintf( |
||
68 | $this->target->errorMessage, |
||
0 ignored issues
–
show
The property
errorMessage 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...
|
|||
69 | $took, |
||
70 | $this->target->maximumTime |
||
71 | ) |
||
72 | ) |
||
73 | : $this->makeHealthyResult(); |
||
74 | |||
75 | $result->setValue($took)->setValueHuman($tookHuman); |
||
76 | |||
77 | return $result; |
||
78 | } |
||
79 | } |
||
80 |
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.