Passed
Push — issue#767 ( b3675b...a787f5 )
by Guilherme
05:11
created

AccessSession::getUsername()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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\CoreBundle\Entity;
12
13
use Doctrine\ORM\Mapping as ORM;
14
15
/**
16
 * City
17
 *
18
 * @ORM\Table(name="access_session")
19
 * @ORM\Entity
20
 * @ORM\HasLifecycleCallbacks
21
 */
22
class AccessSession
23
{
24
25
    /**
26
     *
27
     * @var integer @ORM\Column(name="id", type="integer")
28
     *      @ORM\Id
29
     *      @ORM\GeneratedValue(strategy="AUTO")
30
     */
31
    private $id;
32
33
    /**
34
     *
35
     * @var string @ORM\Column(name="username", type="string", length=255)
36
     */
37
    private $username;
38
39
    /**
40
     *
41
     * @var string @ORM\Column(name="ip", type="string", length=255)
42
     */
43
    private $ip;
44
45
    /**
46
     *
47
     * @var string @ORM\Column(name="dhacess", type="datetime")
48
     */
49
    private $dhacess;
50
51
    /**
52
     *
53
     * @var string @ORM\Column(name="val", type="integer")
54
     */
55
    private $val;
56
57 1
    public function getId()
58
    {
59 1
        return $this->id;
60
    }
61
62 1
    public function setUsername($var)
63
    {
64 1
        $this->username = $var;
65
66 1
        return $this;
67
    }
68
69 1
    public function getUsername()
70
    {
71 1
        return $this->username;
72
    }
73
74 1
    public function setIp($var)
75
    {
76 1
        $this->ip = $var;
77
78 1
        return $this;
79
    }
80
81 1
    public function getIp()
82
    {
83 1
        return $this->ip;
84
    }
85
86 1
    public function setIDhacess($var)
87
    {
88 1
        $this->dhacess = $var;
89
90 1
        return $this;
91
    }
92
93 1
    public function getIDhacess()
94
    {
95 1
        return $this->dhacess;
96
    }
97
98 5
    public function setVal($var)
99
    {
100 5
        $this->val = $var;
101
102 5
        return $this;
103
    }
104
105 6
    public function getVal()
106
    {
107 6
        if ($this->val === null) {
108 4
            $this->val = 0;
109
        }
110 6
        return $this->val;
111
    }
112
113
    /**
114
     * @ORM\PrePersist
115
     * @ORM\PreUpdate
116
     */
117 1
    public function doStuffOnPrePersist()
118
    {
119 1
        $this->setIDhacess(new \DateTime());
120 1
    }
121
122 3
    public function fromArray($var)
123
    {
124 3
        if (isset($var['ip'])) {
125 3
            $this->ip = $var['ip'];
126
        }
127 3
        if (isset($var['username'])) {
128 3
            $this->username = $var['username'];
129
        }
130 3
    }
131
}
132