Completed
Push — master ( 1c61d9...2c0a26 )
by Joe
02:01
created

AbstractWbemObject::toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace PhpWinTools\WmiScripting\Support\ApiObjects;
4
5
use PhpWinTools\Support\COM\ComVariantWrapper;
6
use PhpWinTools\WmiScripting\Contracts\Jsonable;
7
use PhpWinTools\WmiScripting\Contracts\Arrayable;
8
use PhpWinTools\WmiScripting\Concerns\ComHasAttributes;
9
10
/**
11
 * @link https://docs.microsoft.com/en-us/windows/win32/wmisdk/winmgmt
12
 */
13
class AbstractWbemObject implements Arrayable, Jsonable
14
{
15
    use ComHasAttributes;
16
17
    protected $object;
18
19
    protected $merge_parent_casting = true;
20
21
    protected $merge_parent_hidden_attributes = true;
22
23
    protected $hidden_attributes = ['object', 'services', 'resolve_property_sets', 'config'];
24
25 2
    public function __construct(ComVariantWrapper $object)
26
    {
27 2
        $this->object = $object;
28 2
        $this->mergeHiddenAttributes($this->hidden_attributes, $this->merge_parent_hidden_attributes);
29 2
    }
30
31
    public function toJson(): string
32
    {
33
        return json_encode($this->toArray());
34
    }
35
36
    public function toString(): string
37
    {
38
        return $this->toJson();
39
    }
40
41
    public function __toString()
42
    {
43
        return $this->toString();
44
    }
45
}
46