Failed Conditions
Push — issue#767 ( 4d8d6b...78ead8 )
by Guilherme
04:57
created

AccessSession::setUsername()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 9.4285
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
    public function getId()
58
    {
59
        return $this->id;
60
    }
61
62
    public function setUsername($var)
63
    {
64
        $this->username = $var;
65
66
        return $this;
67
    }
68
69
    public function getUsername()
70
    {
71
        return $this->username;
72
    }
73
74
    public function setIp($var)
75
    {
76
        $this->ip = $var;
77
78
        return $this;
79
    }
80
81
    public function getIp()
82
    {
83
        return $this->ip;
84
    }
85
86
    public function setIDhacess($var)
87
    {
88
        $this->dhacess = $var;
89
90
        return $this;
91
    }
92
93
    public function getIDhacess()
94
    {
95
        return $this->dhacess;
96
    }
97
98 3
    public function setVal($var)
99
    {
100 3
        $this->val = $var;
101
102 3
        return $this;
103
    }
104
105 3
    public function getVal()
106
    {
107 3
        if ($this->val === null) {
108 3
            $this->val = 0;
109
        }
110 3
        return $this->val;
111
    }
112
113
    /**
114
     * @ORM\PrePersist
115
     * @ORM\PreUpdate
116
     */
117
    public function doStuffOnPrePersist()
118
    {
119
        $this->setIDhacess(new \DateTime());
120
    }
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