Passed
Push — master ( 122bec...b84cd1 )
by Brian
02:43
created

XmlElement::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Bmatovu\LaravelXml\Support;
4
5
class XmlElement extends \SimpleXMLElement
6
{
7
    /**
8
     * Provides access to element's children.
9
     *
10
     * With chance for default value.
11
     *
12
     * @param string $attr Attribute
13
     * @param mixed $default Default Value
14
     *
15
     * @return mixed
16
     */
17 1
    public function get($attr, $default = null)
18
    {
19 1
        if (is_null($this->{$attr})) {
20 1
            return $default;
21
        }
22
23 1
        return $this->{$attr};
24
    }
25
}
26