Completed
Push — fake_json ( 3414f8...1903bd )
by Akihito
09:01 queued 07:08
created

Link   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 52
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\Annotation;
6
7
/**
8
 * @Annotation
9
 * @Target("METHOD")
10
 */
11
final class Link implements \JsonSerializable
12
{
13
    /**
14
     * Relation to the target resource of the link
15
     *
16
     * @var string
17
     */
18
    public $rel;
19
20
    /**
21
     * A URI template, as defined by RFC 6570
22
     *
23
     * @var string
24
     */
25
    public $href;
26
27
    /**
28
     * A method for the Link
29
     *
30
     * @var string
31
     * @Enum({"get", "post", "put", "patch", "delete"})
32
     */
33
    public $method = 'get';
34
35
    /**
36
     * A title for the link
37
     *
38
     * @var string
39
     */
40
    public $title = '';
41
42
    /**
43
     * Crawl tag ID for crawl request
44
     *
45
     * @var string
46
     */
47
    public $crawl = '';
48
49
    public function jsonSerialize()
50
    {
51
        $json = [
52
            'rel' => $this->rel,
53
            'href' => $this->href,
54
            'method' => $this->method
55
        ];
56
        if ($this->title) {
57
            $json += ['title' => $this->title];
58
        }
59
60
        return $json;
61
    }
62
}
63