VARIANTFake::getIterator()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 25
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 9.9332
c 0
b 0
f 0
cc 4
nc 8
nop 0
crap 4
1
<?php
2
3
namespace PhpWinTools\WmiScripting\Testing\Support;
4
5
use ArrayIterator;
6
use IteratorAggregate;
7
use PhpWinTools\Support\COM\VariantWrapper;
8
use PhpWinTools\Support\COM\Testing\COMObjectFake;
9
use PhpWinTools\WmiScripting\Testing\CallStacks\ComCallStack;
10
use PhpWinTools\WmiScripting\Support\ApiObjects\SWbemObjectSet;
11
use PhpWinTools\WmiScripting\Support\ApiObjects\SWbemPropertySet;
12
use PhpWinTools\WmiScripting\Support\ApiObjects\SWbemQualifierSet;
13
14
class VARIANTFake extends COMObjectFake implements IteratorAggregate
15
{
16
    public $value;
17
18
    public $class_name;
19
20
    public $code_page;
21
22
    public $expectations;
23
24 2
    public function __construct($value = null, string $class_name = null, $code_page = null)
25
    {
26 2
        parent::__construct();
27
28 2
        $this->value = $value;
29 2
        $this->class_name = $class_name;
30 2
        $this->code_page = $code_page;
31 2
    }
32
33 2
    public function getIterator()
34
    {
35 2
        $this->stack->add('iterator');
36
37 2
        $standard = new ArrayIterator([
38 2
            new VariantWrapper(new self()),
39
        ]);
40
41 2
        if (ComCallStack::current()->getCaller()->getClass() === SWbemObjectSet::class) {
42 2
            $response = $this->call(__FUNCTION__, '__objectSet__');
43
        }
44
45 2
        if (ComCallStack::current()->getCaller()->getClass() === SWbemPropertySet::class) {
46 2
            $response = $this->call(__FUNCTION__, '__propertySet__');
47
        }
48
49 2
        if (ComCallStack::current()->getCaller()->getClass() === SWbemQualifierSet::class) {
50 2
            $response = $this->call(__FUNCTION__, '__qualifierSet__');
51
        }
52
53
//        if (!isset($response)) {
54
//            dd(ComCallStack::current());
55
//        }
56
57 2
        return $response ?? $standard;
58
    }
59
}
60