Completed
Push — master ( 5decb7...aee104 )
by Thibaud
14:37 queued 11:26
created

Permalink   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 90.48%

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 12
c 6
b 0
f 0
lcom 1
cbo 0
dl 0
loc 109
ccs 19
cts 21
cp 0.9048
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A fromValue() 0 4 1
A __construct() 0 4 1
A getRawData() 0 4 1
A getId() 0 4 1
A isActivated() 0 4 1
A getLabel() 0 4 1
A getUpdatedOn() 0 4 2
A getCreatedOn() 0 4 2
A getPageUrl() 0 4 1
A getUrl() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of Phraseanet SDK.
5
 *
6
 * (c) Alchemy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhraseanetSDK\Entity;
13
14
class Permalink
15
{
16
17 13
    public static function fromValue(\stdClass $value)
18
    {
19 13
        return new self($value);
20
    }
21
22
    /**
23
     * @var \stdClass
24
     */
25
    protected $source;
26
27
    /**
28
     * @var \DateTimeInterface
29
     */
30
    protected $createdOn;
31
32
    /**
33
     * @var \DateTimeInterface
34
     */
35
    protected $updatedOn;
36
37
    /**
38
     * @param \stdClass $source
39
     */
40 13
    public function __construct(\stdClass $source)
41
    {
42 13
        $this->source = $source;
43 13
    }
44
45
    /**
46
     * @return \stdClass
47
     */
48
    public function getRawData()
49
    {
50
        return $this->source;
51
    }
52
53
    /**
54
     * Get the permalink id
55
     *
56
     * @return integer
57
     */
58 13
    public function getId()
59
    {
60 13
        return $this->source->id;
61
    }
62
63
    /**
64
     * Tell whether the permalink is activated
65
     *
66
     * @return Boolean
67
     */
68 13
    public function isActivated()
69
    {
70 13
        return $this->source->is_activated;
71
    }
72
73
    /**
74
     * get the permalink label
75
     *
76
     * @return string
77
     */
78 13
    public function getLabel()
79
    {
80 13
        return $this->source->label;
81
    }
82
83
    /**
84
     * Last updated date
85
     *
86
     * @return \DateTime
87
     */
88 13
    public function getUpdatedOn()
89
    {
90 13
        return $this->updatedOn ?: $this->updatedOn = new \DateTime($this->source->updated_on);
91
    }
92
93
    /**
94
     * Creation date
95
     *
96
     * @return \DateTime
97
     */
98 13
    public function getCreatedOn()
99
    {
100 13
        return $this->createdOn ?: $this->createdOn = new \DateTime($this->source->created_on);
101
    }
102
103
    /**
104
     * Get the page url
105
     *
106
     * @return string
107
     */
108 13
    public function getPageUrl()
109
    {
110 13
        return $this->source->page_url;
111
    }
112
113
    /**
114
     * Get Url
115
     *
116
     * @return string
117
     */
118 13
    public function getUrl()
119
    {
120 13
        return $this->source->url;
121
    }
122
}
123