Completed
Push — master ( 247290...01d05f )
by Michael
08:30
created

MicroTimeTest::testGetStrength()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * The RandomLib library for securely generating random numbers and strings in PHP
5
 *
6
 * @author     Anthony Ferrara <[email protected]>
7
 * @copyright  2011 The Authors
8
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
9
 * @version    Build @@version@@
10
 */
11
namespace RandomLib\Source;
12
13
use SecurityLib\Strength;
14
15
class MicroTimeTest extends AbstractSourceTest
16
{
17
    protected static function getExpectedStrength()
18
    {
19
        return new Strength(Strength::VERYLOW);
20
    }
21
22
    /**
23
     * Test the initialization of the static counter (!== 0)
24
     */
25
    public function testCounterNotNull()
26
    {
27
        $class = static::getTestedClass();
28
        $rand = new $class();
0 ignored issues
show
Unused Code introduced by
$rand is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
29
        $reflection_class = new \ReflectionClass($class);
30
        $static = $reflection_class->getStaticProperties();
31
        $this->assertTrue($static['counter'] !== 0);
0 ignored issues
show
Unused Code Bug introduced by
The strict comparison !== seems to always evaluate to true as the types of $static['counter'] (string) and 0 (integer) can never be identical. Maybe you want to use a loose comparison != instead?
Loading history...
32
    }
33
}
34