Completed
Push — master ( 5c5d8b...07962b )
by
unknown
04:03 queued 51s
created

Deferred   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 18
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setArgs() 0 3 1
A __destruct() 0 3 1
1
<?php
2
3
/**
4
 * Deferred
5
 *
6
 * Run callback when script execution is stopped.
7
 *
8
 * @package core
9
 * @author [email protected]
10
 * @copyright Caffeina srl - 2016 - http://caffeina.com
11
 */
12
13
class Deferred {
14
15
	protected 	$callback,
16
				$args;
17
18
	public function __construct( callable $callback ) {
19
		$this->args = array_slice( func_get_args(), 1 );
20
		$this->callback = $callback;
21
	}
22
23
	public function setArgs() {
24
		$this->args = func_get_args();
25
	}
26
27
	public function __destruct() {
28
		call_user_func( $this->callback, $this->$args );
0 ignored issues
show
Bug introduced by
The variable $args does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
29
	}
30
}