Uri   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 50
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A call() 0 4 1
A __invoke() 0 4 1
A __toString() 0 4 1
1
<?php
2
namespace Perry\Representation;
3
4
use Perry\Perry;
5
use Perry\Representation\Interfaces\CanRefer;
6
7
/**
8
 * Class Uri
9
 * @property string href
10
 * @package Perry\Representation\Eve\v1
11
 */
12
class Uri extends Base implements CanRefer
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $perryReferredType = null;
18
19
    /**
20
     * @param array|null|object|string $inputData
21
     * @param string $referTo
22
     */
23
    public function __construct($inputData, $referTo = null)
24
    {
25
        // hack, because uri's look different than other references.
26
        $this->href = (string) $inputData;
27
        $this->perryReferredType = $referTo;
28
    }
29
30
    /**
31
     * call method, allows references to be called
32
     *
33
     * @param array $args
34
     * @return Base
35
     * @throws \Exception
36
     */
37
    public function call($args = array())
38
    {
39
        return Perry::fromUrl($this->href, $this->perryReferredType);
40
    }
41
42
    /**
43
     * magic method to allow calling the object as if it was a function
44
     *
45
     * @param array $args
46
     * @return Base
47
     */
48
    public function __invoke($args = array())
49
    {
50
        return $this->call($args);
51
    }
52
53
    /**
54
     * Magic to String
55
     * @return string
56
     */
57
    public function __toString()
58
    {
59
        return $this->href;
60
    }
61
}
62