Completed
Push — master ( e79dfa...ffecda )
by Benjamin
02:16
created

User::getParent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Alpixel\Bundle\UserBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use FOS\UserBundle\Entity\User as BaseUser;
7
8
abstract class User extends BaseUser
9
{
10
    /**
11
     * @var string
12
     *
13
     * @ORM\Column(name="created", type="datetime", nullable=false)
14
     */
15
    protected $created;
16
17
    /**
18
     * @var string
19
     *
20
     * @ORM\Column(name="activated", type="boolean")
21
     */
22
    protected $activated;
23
24
    public function __construct()
25
    {
26
        parent::__construct();
27
        $this->pushID               = array();
0 ignored issues
show
Bug introduced by
The property pushID does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
        $this->confirmationToken    = sha1(uniqid(uniqid(mt_rand()), true));
29
        $this->created              = new \DateTime();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \DateTime() of type object<DateTime> is incompatible with the declared type string of property $created.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
30
        $this->activated            = false;
0 ignored issues
show
Documentation Bug introduced by
The property $activated was declared of type string, but false is of type false. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
31
        $this->enabled              = true;
32
    }
33
34
    public function getWSSEToken()
35
    {
36
        $nonce = hash_hmac('sha512', uniqid(null, true), uniqid(), true);
37
        $created = new \DateTime('now');
38
        $created = $created->format(\DateTime::ISO8601);
39
        $digest = sha1($nonce.$created.$this->getPassword(), true);
40
41
        return sprintf(
42
            'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',
43
            $this->getUsername(),
44
            $digest,
45
            $nonce,
46
            $created
47
        );
48
    }
49
50
    public function __toString()
51
    {
52
        return $this->firstname.' '.$this->lastname;
0 ignored issues
show
Bug introduced by
The property firstname does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property lastname does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
53
    }
54
55
    public function getParent()
56
    {
57
        return 'FOSUserBundle';
58
    }
59
60
    /**
61
     * Gets the value of id.
62
     *
63
     * @return integer
64
     */
65
    public function getID()
66
    {
67
        return $this->id;
68
    }
69
70
    /**
71
     * Sets the value of id.
72
     *
73
     * @param integer $id the id
74
     *
75
     * @return self
76
     */
77
    protected function setID($id)
78
    {
79
        $this->id = $id;
80
81
        return $this;
82
    }
83
84
    /**
85
     * Gets the value of newPassword.
86
     *
87
     * @return string
88
     */
89
    public function getNewPassword()
90
    {
91
        return $this->newPassword;
0 ignored issues
show
Bug introduced by
The property newPassword does not seem to exist. Did you mean password?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
92
    }
93
94
    /**
95
     * Sets the value of newPassword.
96
     *
97
     * @param string $newPassword the new password
98
     *
99
     * @return self
100
     */
101
    public function setNewPassword($newPassword)
102
    {
103
        $this->newPassword = $newPassword;
0 ignored issues
show
Bug introduced by
The property newPassword does not seem to exist. Did you mean password?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
104
105
        return $this;
106
    }
107
108
    /**
109
     * Gets the value of uniqid.
110
     *
111
     * @return string
112
     */
113
    public function getUniqid()
114
    {
115
        return $this->uniqid;
0 ignored issues
show
Bug introduced by
The property uniqid does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
116
    }
117
118
    /**
119
     * Sets the value of uniqid.
120
     *
121
     * @param string $uniqid the uniqid
122
     *
123
     * @return self
124
     */
125
    public function setUniqid($uniqid)
126
    {
127
        $this->uniqid = $uniqid;
128
129
        return $this;
130
    }
131
132
    /**
133
     * Gets the value of created.
134
     *
135
     * @return string
136
     */
137
    public function getCreated()
138
    {
139
        return $this->created;
140
    }
141
142
    /**
143
     * Sets the value of created.
144
     *
145
     * @param string $created the subscription date
146
     *
147
     * @return self
148
     */
149
    public function setCreated($created)
150
    {
151
        $this->created = $created;
152
153
        return $this;
154
    }
155
156
    public function isActivated()
157
    {
158
        return $this->activated;
159
    }
160
161
    public function setActivated($activated)
162
    {
163
        $this->activated = $activated;
164
    }
165
}
166