User::getCreated()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
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\Model\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->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...
28
        $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...
29
        $this->enabled = true;
30
    }
31
32
    public function getWSSEToken()
33
    {
34
        $nonce = hash_hmac('sha512', uniqid(null, true), uniqid(), true);
35
        $created = new \DateTime('now');
36
        $created = $created->format(\DateTime::ISO8601);
37
        $digest = sha1($nonce.$created.$this->getPassword(), true);
38
39
        return sprintf(
40
            'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',
41
            $this->getUsername(),
42
            $digest,
43
            $nonce,
44
            $created
45
        );
46
    }
47
48
    public function __toString()
49
    {
50
        return $this->username;
51
    }
52
53
    public function getParent()
54
    {
55
        return 'FOSUserBundle';
56
    }
57
58
    /**
59
     * Gets the value of created.
60
     *
61
     * @return string
62
     */
63
    public function getCreated()
64
    {
65
        return $this->created;
66
    }
67
68
    /**
69
     * Sets the value of created.
70
     *
71
     * @param string $created the created
72
     *
73
     * @return self
74
     */
75
    public function setCreated($created)
76
    {
77
        $this->created = $created;
78
79
        return $this;
80
    }
81
82
    /**
83
     * Gets the value of activated.
84
     *
85
     * @return string
86
     */
87
    public function getActivated()
88
    {
89
        return $this->activated;
90
    }
91
92
    /**
93
     * Sets the value of activated.
94
     *
95
     * @param string $activated the activated
96
     *
97
     * @return self
98
     */
99
    public function setActivated($activated)
100
    {
101
        $this->activated = $activated;
102
103
        return $this;
104
    }
105
}
106