public function testGetConstListWithDefault()
 {
     $obj = new Strength();
     $const = $obj->getConstList(true);
     $this->assertEquals(array('__DEFAULT' => 1, 'VERYLOW' => 1, 'LOW' => 3, 'MEDIUM' => 5, 'HIGH' => 7), $const);
 }
Esempio n. 2
0
 /**
  * Find a mixer based upon the requested strength
  *
  * @param Strength $strength The strength mixer to find
  *
  * @return Mixer The found mixer
  * @throws RuntimeException if a valid mixer cannot be found
  */
 protected function findMixer(\PasswordLib\Core\Strength $strength)
 {
     $newMixer = null;
     $fallback = null;
     foreach ($this->getMixers() as $mixer) {
         if ($strength->compare($mixer::getStrength()) == 0) {
             $newMixer = new $mixer();
         } elseif ($strength->compare($mixer::getStrength()) == 1) {
             $fallback = new $mixer();
         }
     }
     if (is_null($newMixer)) {
         if (is_null($fallback)) {
             throw new \RuntimeException('Could not find mixer');
         }
         return $fallback;
     }
     return $newMixer;
 }