Completed
Push — master ( 5c9671...053307 )
by Sebastian
02:47
created

Token::setValue()   A

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
2
namespace Kartenmacherei\RestFramework;
3
4
class Token
5
{
6
    /**
7
     * @var string
8
     */
9
    private $value = '';
10
11
    /**
12
     * @param null $value
13
     */
14
    public function __construct($value = NULL)
15
    {
16
        if (NULL !== $value) {
17
            $this->value = $value;
18
        } else {
19
            $this->setValue();
20
        }
21
    }
22
23
    /**
24
     *
25
     */
26
    private function setValue()
27
    {
28
        $this->value = bin2hex(random_bytes(16));
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function asString(): string
35
    {
36
        return $this->value;
37
    }
38
39
}
40