helpers.php ➔ td()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
if (! function_exists('tinker')) {
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) {
0 ignored issues
show
Unused Code introduced by
The parameter $function is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
                return file($filePath)[$lineNumber - 1];
17
                // "    tinker($post, new User);"
18
            })->map(function ($carry) {
19
                return str_before(str_after($carry, 'tinker('), ');');
0 ignored issues
show
Deprecated Code introduced by
The function str_after() has been deprecated with message: Str::after() should be used directly instead. Will be removed in Laravel 6.0.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
Deprecated Code introduced by
The function str_before() has been deprecated with message: Str::before() should be used directly instead. Will be removed in Laravel 6.0.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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, '$')
0 ignored issues
show
Deprecated Code introduced by
The function str_after() has been deprecated with message: Str::after() should be used directly instead. Will be removed in Laravel 6.0.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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
}
39
40
if (! function_exists('td')) {
41
    function td(...$args)
42
    {
43
        tinker($args);
44
45
        die(1);
46
    }
47
}
48