HalLink::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the Hal library
4
 *
5
 * (c) Ben Longden <[email protected]
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @package Nocarrier
11
 */
12
namespace Nocarrier;
13
14
/**
15
 * The HalLink class
16
 *
17
 * @package Nocarrier
18
 * @author Ben Longden <[email protected]>
19
 */
20
class HalLink
21
{
22
    /**
23
     * The URI represented by this HalLink.
24
     *
25
     * @var string
26
     */
27
    protected $uri;
28
29
    /**
30
     * Any attributes on this link.
31
     *
32
     * array(
33
     *  'templated' => 0,
34
     *  'type' => 'application/hal+json',
35
     *  'deprecation' => 1,
36
     *  'name' => 'latest',
37
     *  'profile' => 'http://.../profile/order',
38
     *  'title' => 'The latest order',
39
     *  'hreflang' => 'en'
40
     * )
41
     *
42
     * @var array
43
     */
44
    protected $attributes;
45
46
    /**
47
     * The \Nocarrier\HalLink object.
48
     *
49
     * Supported attributes in Hal (specification section 5).
50
     *
51
     * @param string $uri
52
     *   The URI represented by this link.
53
     * @param array $attributes
54
     *   Any additional attributes.
55
     */
56
    public function __construct($uri, $attributes)
57
    {
58
        $this->uri = $uri;
59
        $this->attributes = $attributes;
60
    }
61
62
    /**
63
     * Return the URI from this link.
64
     *
65
     * @return string
66
     */
67
    public function getUri()
68
    {
69
        return $this->uri;
70
    }
71
72
    /**
73
     * Returns the attributes for this link.
74
     *
75
     * return array
76
     */
77
    public function getAttributes()
78
    {
79
        return $this->attributes;
80
    }
81
82
    /**
83
     * The string representation of this link (the URI).
84
     *
85
     * return string
86
     */
87
    public function __toString()
88
    {
89
        return $this->uri;
90
    }
91
}
92