Completed
Push — work-fleets ( ad253d...d9c01a )
by SuperNova.WS
06:45
created

Invoker   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
ccs 0
cts 9
cp 0
rs 10
wmc 6
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A build() 0 7 4
A __invoke() 0 3 1
1
<?php
2
/**
3
 * Created by Gorlum 21.08.2016 13:33
4
 */
5
6
namespace Common;
7
8
9
class Invoker {
10
11
  protected $callable;
12
13
  public function __construct($callable) {
14
    $this->callable = $callable;
15
  }
16
17
  public static function build($callable) {
18
    if(is_array($callable) && count($callable) == 2 && is_object($callable[0])) {
19
      return new static($callable);
20
    } else {
21
      return false;
22
    }
23
  }
24
25
  public function __invoke() {
26
    return call_user_func_array($this->callable, func_get_args());
27
  }
28
29
}
30