RequestUrlHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 20
ccs 3
cts 4
cp 0.75
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getObjectProperty() 0 7 2
1
<?php
2
3
namespace DMT\Aura\Psr\Helpers;
4
5
use Aura\Web\Request\Url as RequestUrl;
6
use InvalidArgumentException;
7
8
/**
9
 * Class RequestUrlHelper
10
 *
11
 * This helper allows access to the Aura Request Url parts property.
12
 *
13
 * @package DMT\Aura\Psr\Helpers
14
 */
15
class RequestUrlHelper extends RequestUrl implements PropertyAccessorInterface
16
{
17
    use PropertyAccessorTrait;
18
19
    /**
20
     * Access a property.
21
     *
22
     * @param string $property the property to access.
23
     * @param mixed|null $default the default value.
24
     *
25
     * @return mixed
26
     * @throws InvalidArgumentException when property does not exists
27
     */
28 3
    public function getObjectProperty($property, $default = null)
29
    {
30 3
        if (!property_exists($this->object, $property)) {
31
            throw new InvalidArgumentException('property does not exists');
32
        }
33
34 3
        return $this->object->{$property} ?? $default;
35
    }
36
}
37