| Conditions | 4 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | public function register() |
||
| 11 | { |
||
| 12 | $raw = function ($sql, $bindings) { |
||
| 13 | $flat = array_flatten($bindings); |
||
| 14 | foreach ($flat as $binding) { |
||
| 15 | $binded = $binding instanceof \DateTime ? $binding->format('Y-m-d H:i:s') : $binding; |
||
| 16 | $binded = is_numeric($binded) ? $binded : "'{$binded}'"; |
||
| 17 | $sql = preg_replace('/\?/', $binded, $sql, 1); |
||
| 18 | } |
||
| 19 | |||
| 20 | return $sql; |
||
| 21 | }; |
||
| 22 | |||
| 23 | Builder::macro('dump', function ($dumper = 'dump') use ($raw) { |
||
| 24 | $dumper([ |
||
| 25 | 'bindings' => $this->bindings, |
||
|
|
|||
| 26 | 'sql' => $this->toSql(), |
||
| 27 | 'raw' => $raw($this->toSql(), $this->bindings), |
||
| 28 | ]); |
||
| 29 | |||
| 30 | return $this; |
||
| 31 | }); |
||
| 32 | } |
||
| 33 | } |
||
| 34 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: