Completed
Push — master ( 4d4232...ffcfa4 )
by Anthony
14:02 queued 11:53
created

AbstractSource   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getStrength() 0 3 1
A isSupported() 0 3 1
A emptyValue() 0 3 1
1
<?php
2
/**
3
 * PHP version 5.3
4
 *
5
 * @category  PHPSecurityLib
6
 * @package   Random
7
 * @author    Anthony Ferrara <[email protected]>
8
 * @copyright 2011 The Authors
9
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
10
 * @version   Build @@version@@
11
 */
12
13
namespace RandomLib;
14
15
use SecurityLib\Strength;
16
17
/**
18
 * An abstract mixer to implement a common mixing strategy
19
 *
20
 * @category PHPSecurityLib
21
 * @package  Random
22
 */
23
abstract class AbstractSource implements \RandomLib\Source {
24
25
    /**
26
     * Return an instance of Strength indicating the strength of the source
27
     *
28
     * @return \SecurityLib\Strength An instance of one of the strength classes
29
     */
30
    public static function getStrength() {
31
        return new Strength(Strength::VERYLOW);
32
    }
33
34
    /**
35
     * If the source is currently available.
36
     * Reasons might be because the library is not installed
37
     *
38
     * @return boolean
39
     */
40
    public static function isSupported() {
41
        return true;
42
    }
43
44
    /**
45
     * Returns a string of zeroes, useful when no entropy is available.
46
     *
47
     * @param int $size The size of the requested random string
48
     *
49
     * @return string A string of the requested size
50
     */
51
    protected static function emptyValue($size) {
52
        return str_repeat(chr(0), $size);
53
    }
54
55
}
56