Mixer.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /*
  3. * The RandomLib library for securely generating random numbers and strings in PHP
  4. *
  5. * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
  6. * @copyright 2011 The Authors
  7. * @license http://www.opensource.org/licenses/mit-license.html MIT License
  8. * @version Build @@version@@
  9. */
  10. /**
  11. * The Mixer strategy interface.
  12. *
  13. * All mixing strategies must implement this interface
  14. *
  15. * PHP version 5.3
  16. *
  17. * @category PHPPasswordLib
  18. * @package Random
  19. *
  20. * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
  21. * @copyright 2011 The Authors
  22. * @license http://opensource.org/licenses/bsd-license.php New BSD License
  23. * @license http://www.gnu.org/licenses/lgpl-2.1.html LGPL v 2.1
  24. */
  25. namespace RandomLibtest\Mocks\Random;
  26. use SecurityLib\Strength;
  27. /**
  28. * The Mixer strategy interface.
  29. *
  30. * All mixing strategies must implement this interface
  31. *
  32. * @category PHPPasswordLib
  33. * @package Random
  34. *
  35. * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
  36. */
  37. class Mixer extends \RandomLibTest\Mocks\AbstractMock implements \RandomLib\Mixer
  38. {
  39. public static $strength = null;
  40. public static $test = true;
  41. public static function init()
  42. {
  43. static::$strength = new Strength(Strength::HIGH);
  44. static::$test = true;
  45. }
  46. /**
  47. * Return an instance of Strength indicating the strength of the mixer
  48. *
  49. * @return \SecurityLib\Strength An instance of one of the strength classes
  50. */
  51. public static function getStrength()
  52. {
  53. return static::$strength;
  54. }
  55. /**
  56. * Test to see if the mixer is available
  57. *
  58. * @return bool If the mixer is available on the system
  59. */
  60. public static function test()
  61. {
  62. return static::$test;
  63. }
  64. /**
  65. * Mix the provided array of strings into a single output of the same size
  66. *
  67. * All elements of the array should be the same size.
  68. *
  69. * @param array $parts The parts to be mixed
  70. *
  71. * @return string The mixed result
  72. */
  73. public function mix(array $parts)
  74. {
  75. return $this->__call('mix', array($parts));
  76. }
  77. }