Passed
Push — master ( 4f9e3a...139be2 )
by Alexander
23:24
created

XmlConvertibleObject::__set()   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
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Horat1us;
4
5
/**
6
 * Class XmlConvertibleObject
7
 * @package Horat1us
8
 */
9
class XmlConvertibleObject implements XmlConvertibleInterface
10
{
11
    use XmlConvertible {
12
        getXmlProperties as protected traitXmlProperties;
13
    }
14
15
    private array $xmlProperties = [];
16
17
    /**
18
     * XmlConvertibleObject constructor.
19
     * @param string $xmlElementName
20
     * @param array $xmlChildren
21
     */
22
    public function __construct(?string $xmlElementName = null, array $xmlChildren = null)
23
    {
24
        $this->xmlElementName = $xmlElementName;
25
        $this->xmlChildren = $xmlChildren;
26
    }
27 19
28
    /**
29 19
     * @param array|null $properties
30 19
     * @return array
31 19
     */
32
    public function getXmlProperties(?array $properties = null): array
33
    {
34
        return $this->traitXmlProperties($properties ?? array_keys($this->xmlProperties));
35
    }
36
37 14
    public function __get(string $name)
38
    {
39 14
        return $this->xmlProperties[$name] ?? null;
40
    }
41
42
    public function __set(string $name, $value): void
43
    {
44
        $this->xmlProperties[$name] = $value;
45
    }
46
}
47