Conditions | 3 |
Paths | 3 |
Total Lines | 25 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
48 | 3 | public function call( $func, $args = null ) { |
|
49 | |||
50 | 3 | if ( !is_callable( $func ) ) { |
|
51 | 1 | throw new RuntimeException( "Function is not callable" ); |
|
52 | } |
||
53 | |||
54 | 2 | declare( ticks=1 ); |
|
55 | |||
56 | 2 | self::$memory = memory_get_usage(); |
|
57 | 2 | self::$max = 0; |
|
58 | |||
59 | 2 | register_tick_function( |
|
60 | 2 | 'call_user_func_array', |
|
61 | 2 | array( '\Onoi\CallbackContainer\CallFuncMemorySniffer', 'memoryTick' ), |
|
62 | 2 | array() |
|
63 | 2 | ); |
|
64 | |||
65 | 2 | $this->time = microtime( true ); |
|
|
|||
66 | 2 | $result = is_array( $args ) ? call_user_func_array( $func, $args ): call_user_func( $func ); |
|
67 | 2 | $this->time = microtime( true ) - $this->time; |
|
68 | |||
69 | 2 | unregister_tick_function( 'call_user_func_array' ); |
|
70 | |||
71 | 2 | return $result; |
|
72 | } |
||
73 | |||
93 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.