Conditions | 5 |
Paths | 5 |
Total Lines | 30 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 5.0042 |
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 | // HHVM ... Fatal error: Call to undefined function |
||
55 | 2 | if ( !function_exists( 'register_tick_function' ) ) { |
|
56 | return is_array( $args ) ? call_user_func_array( $func, $args ): call_user_func( $func ); |
||
57 | } |
||
58 | |||
59 | 2 | declare( ticks=1 ); |
|
60 | |||
61 | 2 | self::$memory = memory_get_usage(); |
|
62 | 2 | self::$max = 0; |
|
63 | |||
64 | 2 | register_tick_function( |
|
65 | 2 | 'call_user_func_array', |
|
66 | 2 | array( '\Onoi\CallbackContainer\CallFuncMemorySniffer', 'memoryTick' ), |
|
67 | 2 | array() |
|
68 | 2 | ); |
|
69 | |||
70 | 2 | $this->time = microtime( true ); |
|
|
|||
71 | 2 | $result = is_array( $args ) ? call_user_func_array( $func, $args ): call_user_func( $func ); |
|
72 | 2 | $this->time = microtime( true ) - $this->time; |
|
73 | |||
74 | 2 | unregister_tick_function( 'call_user_func_array' ); |
|
75 | |||
76 | 2 | return $result; |
|
77 | } |
||
78 | |||
98 |
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.