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

Source   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A getStrength() 0 4 1
A isSupported() 0 4 1
A generate() 0 4 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
 * The Random Number Source interface.
14
 *
15
 * All random number sources must implement this interface
16
 *
17
 * PHP version 5.3
18
 *
19
 * @category   PHPPasswordLib
20
 * @package    Random
21
 *
22
 * @author     Anthony Ferrara <[email protected]>
23
 * @copyright  2011 The Authors
24
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
25
 * @license    http://www.gnu.org/licenses/lgpl-2.1.html LGPL v 2.1
26
 */
27
namespace RandomLibtest\Mocks\Random;
28
29
use SecurityLib\Strength;
30
31
/**
32
 * The Random Number Source interface.
33
 *
34
 * All random number sources must implement this interface
35
 *
36
 * @category   PHPPasswordLib
37
 * @package    Random
38
 *
39
 * @author     Anthony Ferrara <[email protected]>
40
 */
41
class Source extends \RandomLibTest\Mocks\AbstractMock implements \RandomLib\Source
42
{
43
    public static $strength = null;
44
45
    public static function init()
46
    {
47
        static::$strength = new Strength(Strength::VERYLOW);
48
    }
49
50
    /**
51
     * Return an instance of Strength indicating the strength of the source
52
     *
53
     * @return \SecurityLib\Strength An instance of one of the strength classes
54
     */
55
    public static function getStrength()
56
    {
57
        return static::$strength;
58
    }
59
60
    /**
61
     * If the source is currently available.
62
     * Reasons might be because the library is not installed
63
     *
64
     * @return bool
65
     */
66
    public static function isSupported()
67
    {
68
        return true;
69
    }
70
71
    /**
72
     * Generate a random string of the specified size
73
     *
74
     * Note: If the source fails to generate enough data, the result must be
75
     * padded to the requested length.
76
     *
77
     * @param int $size The size of the requested random string
78
     *
79
     * @return string A string of the requested size
80
     */
81
    public function generate($size)
82
    {
83
        return $this->__call('generate', array($size));
84
    }
85
}
86