Completed
Push — master ( fc2b8b...a482e0 )
by Sebastian
03:04
created

Token   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A _setValue() 0 4 1
A asString() 0 4 1
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