UnitTestPublicReferenceGenerator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 2
1
<?php
2
/**
3
 * File was created 12.10.2015 06:53
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Helper;
7
8
use PeekAndPoke\Component\Slumber\Data\Addon\PublicReference\PublicReferenceGenerator;
9
10
/**
11
 * @author Karsten J. Gerber <[email protected]>
12
 */
13
class UnitTestPublicReferenceGenerator implements PublicReferenceGenerator
14
{
15
    private $used = [];
16
17
    /**
18
     * @param mixed $subject The object to create a public unique reference for
19
     *
20
     * @return string
21
     */
22 26
    public function create($subject)
23
    {
24 26
        $reflect = new \ReflectionClass($subject);
25
26
        do {
27 26
            $reference = $reflect->getName() . '@' . mt_rand();
0 ignored issues
show
Bug introduced by
Consider using $reflect->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
28 26
        } while (\in_array($reference, $this->used, true));
29
30 26
        $this->used[] = $reference;
31
32 26
        return $reference;
33
    }
34
}
35