ComResolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 15
dl 0
loc 33
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A instance() 0 3 1
A __construct() 0 5 1
A resolve() 0 9 1
1
<?php
2
3
namespace PhpWinTools\WmiScripting\Testing\Support;
4
5
use PhpWinTools\WmiScripting\Configuration\Config;
6
use PhpWinTools\WmiScripting\Testing\CallStacks\ComCallStack;
7
use PhpWinTools\WmiScripting\Testing\CallStacks\ApiObjectCall;
8
use PhpWinTools\WmiScripting\Testing\CallStacks\ApiObjectCallStack;
9
10
class ComResolver
11
{
12
    protected static $instance;
13
14
    protected $callStack;
15
16
    protected $apiCallStack;
17
18
    protected $config;
19
20
    protected $arguments;
21
22 2
    public function __construct(ComCallStack $stack = null, ApiObjectCallStack $apiStack = null, Config $config = null)
23
    {
24 2
        $this->callStack = $stack ?? ComCallStack::instance();
25 2
        $this->apiCallStack = $apiStack ?? ApiObjectCallStack::instance();
26 2
        $this->config = $config ?? Config::testInstance();
27 2
    }
28
29 2
    public static function instance(ComCallStack $callStack)
30
    {
31 2
        return static::$instance ?? new static($callStack);
32
    }
33
34 2
    public function resolve()
35
    {
36 2
        $current = $this->callStack->getCurrent();
37 2
        $class_context = $current->getApiCaller()->getClass();
38 2
        $called = $current->getMethod();
39
40 2
        $this->apiCallStack->add(new ApiObjectCall($class_context, $called, $current->getArguments()));
41
42 2
        return ($this->config)("{$class_context}.{$called}");
43
    }
44
}
45