TokenProvider::generate()   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
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Understand\UnderstandLumen;
2
3
class TokenProvider
4
{
5
6
    /**
7
     * Current token
8
     *
9
     * @var type
10
     */
11
    protected $token;
12
13
    /**
14
     * Generate and set new token
15
     */
16
    public function __construct()
17
    {
18
        $this->generate();
19
    }
20
21
    /**
22
     * Return token
23
     *
24
     * @return string
25
     */
26
    public function getToken()
27
    {
28
        return $this->token;
29
    }
30
31
    /**
32
     * Generate new token
33
     *
34
     * @return string
35
     */
36
    public function generate()
37
    {
38
        $this->token = $this->getUuid();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getUuid() of type string is incompatible with the declared type object<Understand\UnderstandLumen\type> of property $token.

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...
39
    }
40
41
    /**
42
     * Return unique string
43
     *
44
     * @return string
45
     */
46
    protected function getUuid()
47
    {
48
        // http://stackoverflow.com/questions/2040240/php-function-to-generate-v4-uuid
49
        // by Andrew Moore (http://www.php.net/manual/en/function.uniqid.php#94959)
50
        return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
51
            // 32 bits for "time_low"
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
52
            mt_rand(0, 0xffff), mt_rand(0, 0xffff),
53
            // 16 bits for "time_mid"
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
54
            mt_rand(0, 0xffff),
55
            // 16 bits for "time_hi_and_version",
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
56
            // four most significant bits holds version number 4
57
            mt_rand(0, 0x0fff) | 0x4000,
58
            // 16 bits, 8 bits for "clk_seq_hi_res",
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
59
            // 8 bits for "clk_seq_low",
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
60
            // two most significant bits holds zero and one for variant DCE1.1
61
            mt_rand(0, 0x3fff) | 0x8000,
62
            // 48 bits for "node"
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
63
            mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
64
        );
65
    }
66
}