Reference::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
namespace Perry\Representation;
3
4
use Perry\Perry;
5
use Perry\Representation\Interfaces\CanRefer;
6
7
/**
8
 * Class Reference
9
 * @property string href
10
 * @package Perry\Representation\Eve\v1
11
 */
12
class Reference 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
        parent::__construct($inputData);
26
        $this->perryReferredType = $referTo;
27
    }
28
29
    /**
30
     * call method, allows references to be called
31
     *
32
     * @param array $args
33
     * @return Base
34
     * @throws \Exception
35
     */
36
    public function call($args = array())
37
    {
38
        return Perry::fromUrl($this->href, $this->perryReferredType);
39
    }
40
41
    /**
42
     * magic method to allow calling the object as if it was a function
43
     *
44
     * @param array $args
45
     * @return Base
46
     */
47
    public function __invoke($args = array())
48
    {
49
        return $this->call($args);
50
    }
51
}
52