| Conditions | 3 |
| Paths | 2 |
| Total Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 4 | function tinker(...$args) |
||
| 5 | { |
||
| 6 | /* |
||
| 7 | * Thank you Caleb |
||
| 8 | * See: https://github.com/calebporzio/awesome-helpers/blob/master/src/helpers/tinker.php |
||
| 9 | */ |
||
| 10 | $namedParameters = collect(debug_backtrace()) |
||
| 11 | ->where('function', 'tinker')->take(1) |
||
| 12 | ->map(function ($slice) { |
||
| 13 | return array_values($slice); |
||
| 14 | }) |
||
| 15 | ->mapSpread(function ($filePath, $lineNumber, $function, $args) { |
||
| 16 | return file($filePath)[$lineNumber - 1]; |
||
| 17 | // " tinker($post, new User);" |
||
| 18 | })->map(function ($carry) { |
||
| 19 | return str_before(str_after($carry, 'tinker('), ');'); |
||
| 20 | // "$post, new User" |
||
| 21 | })->flatMap(function ($carry) { |
||
| 22 | return array_map('trim', explode(',', $carry)); |
||
| 23 | // ["post", "new User"] |
||
| 24 | })->map(function ($carry, $index) { |
||
| 25 | return strpos($carry, '$') === 0 |
||
| 26 | ? str_after($carry, '$') |
||
| 27 | : 'temp'.$index; |
||
| 28 | // ["post", "temp1"] |
||
| 29 | }) |
||
| 30 | ->combine($args)->all(); |
||
| 31 | |||
| 32 | $connection = new \RedMoon\TinkerServer\Connection(config('tinker-server.host')); |
||
| 33 | |||
| 34 | if (! $connection->write($namedParameters)) { |
||
| 35 | dump($args); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | } |
||
| 48 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.