TimeReferenceGenerator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 10 1
1
<?php
2
3
namespace Matks\Bundle\CustomerSupportBundle\Reference;
4
5
use DateTime;
6
7
/**
8
 * Time Reference Generator
9
 *
10
 * @author Mathieu Ferment <[email protected]>
11
 */
12
class TimeReferenceGenerator implements ReferenceGeneratorInterface
13
{
14
15
    /**
16
     * Generate unique reference based on current time
17
     *
18
     * @param array $options
19
     *
20
     * @return string
21
     */
22 1
    public function generate(array $options)
23
    {
24 1
        $randomPart = rand(100, 999);
25
26 1
        list($usec, $sec) = explode(' ', microtime());
27
28 1
        $microtime = explode('.', $usec)[1];
29 1
        $datetime  = (new DateTime())->format('YmdHis');
30
31 1
        return $datetime . $microtime . $randomPart;
32
    }
33
34
}
35