Uri::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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