| Conditions | 5 |
| Paths | 5 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | function get_db_queries(): array |
||
| 45 | { |
||
| 46 | if (! app()->bound('debugbar')) { |
||
| 47 | return []; |
||
| 48 | } |
||
| 49 | /** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */ |
||
| 50 | $debugbar = app('debugbar'); |
||
| 51 | |||
| 52 | try { |
||
| 53 | $collector = $debugbar->getCollector('queries'); |
||
| 54 | } catch (Throwable $e) { |
||
| 55 | return []; |
||
| 56 | } |
||
| 57 | |||
| 58 | $queries = $collector->collect(); |
||
| 59 | if (empty($queries['statements'])) { |
||
| 60 | return []; |
||
| 61 | } |
||
| 62 | |||
| 63 | $list = []; |
||
| 64 | foreach ($queries['statements'] as $query) { |
||
| 65 | $list[] = $query['sql']; |
||
| 66 | } |
||
| 67 | |||
| 68 | return $list; |
||
| 69 | } |
||
| 70 | } |
||
| 71 |