Completed
Push — master ( c3efa2...a812ec )
by Guilherme
13s
created

AccessToken   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 69
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setExpired() 0 5 1
A getIdToken() 0 4 1
A setIdToken() 0 6 1
A getCreatedAt() 0 4 1
A setCreatedAtValue() 0 6 2
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\OAuthBundle\Entity;
12
13
use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken;
14
use JMS\Serializer\Annotation as JMS;
15
use Doctrine\ORM\Mapping as ORM;
16
17
/**
18
 * @ORM\Entity(repositoryClass="LoginCidadao\OAuthBundle\Entity\AccessTokenRepository")
19
 * @ORM\Table(name="access_token")
20
 * @ORM\HasLifecycleCallbacks
21
 * @ORM\AttributeOverrides({
22
 *      @ORM\AttributeOverride(name="scope",
23
 *          column=@ORM\Column(
24
 *              name     = "scope",
25
 *              type     = "string",
26
 *              length   = 1000,
27
 *              nullable = true
28
 *          )
29
 *      )
30
 * })
31
 */
32
class AccessToken extends BaseAccessToken
33
{
34
    /**
35
     * @ORM\Id
36
     * @ORM\Column(type="integer")
37
     * @ORM\GeneratedValue(strategy="AUTO")
38
     */
39
    protected $id;
40
41
    /**
42
     * @ORM\ManyToOne(targetEntity="Client")
43
     * @ORM\JoinColumn(nullable=false)
44
     */
45
    protected $client;
46
47
    /**
48
     * @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\Person")
49
     */
50
    protected $user;
51
52
    /**
53
     * @ORM\Column(name="id_token", type="text", nullable=true)
54
     * @var string
55
     */
56
    protected $idToken;
57
58
    /**
59
     * @ORM\Column(name="created_at", type="datetime", nullable=true)
60
     * @JMS\Since("1.14")
61
     * @var \DateTime
62
     */
63
    protected $createdAt;
64
65
    public function setExpired()
66
    {
67
        $now = new \DateTime();
68
        $this->setExpiresAt($now->getTimestamp());
69
    }
70
71
    public function getIdToken()
72
    {
73
        return $this->idToken;
74
    }
75
76
    public function setIdToken($idToken)
77
    {
78
        $this->idToken = $idToken;
79
80
        return $this;
81
    }
82
83
    /**
84
     * @return \DateTime
85
     */
86
    public function getCreatedAt()
87
    {
88
        return $this->createdAt;
89
    }
90
91
    /**
92
     * @ORM\PrePersist
93
     */
94
    public function setCreatedAtValue()
95
    {
96
        if (!($this->getCreatedAt() instanceof \DateTime)) {
97
            $this->createdAt = new \DateTime();
98
        }
99
    }
100
}
101