Completed
Push — master ( fc2b8b...a482e0 )
by Sebastian
03:04
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