AbstractSource::emptyValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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
12
/**
13
 * PHP version 5.3
14
 *
15
 * @category  PHPSecurityLib
16
 * @package   Random
17
 *
18
 * @author    Anthony Ferrara <[email protected]>
19
 * @copyright 2011 The Authors
20
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
21
 *
22
 * @version   Build @@version@@
23
 */
24
namespace RandomLib;
25
26
use SecurityLib\Strength;
27
28
/**
29
 * An abstract mixer to implement a common mixing strategy
30
 *
31
 * @category PHPSecurityLib
32
 * @package  Random
33
 */
34
abstract class AbstractSource implements \RandomLib\Source
35
{
36
37
    /**
38
     * Return an instance of Strength indicating the strength of the source
39
     *
40
     * @return \SecurityLib\Strength An instance of one of the strength classes
41
     */
42
    public static function getStrength()
43
    {
44
        return new Strength(Strength::VERYLOW);
45
    }
46
47
    /**
48
     * If the source is currently available.
49
     * Reasons might be because the library is not installed
50
     *
51
     * @return bool
52
     */
53
    public static function isSupported()
54
    {
55
        return true;
56
    }
57
58
    /**
59
     * Returns a string of zeroes, useful when no entropy is available.
60
     *
61
     * @param int $size The size of the requested random string
62
     *
63
     * @return string A string of the requested size
64
     */
65
    protected static function emptyValue($size)
66
    {
67
        return str_repeat(chr(0), $size);
68
    }
69
}
70