[Form] refactor Guess

This commit is contained in:
Tobias Schultze 2012-08-27 06:23:43 +02:00
parent dcbeeb1df7
commit e7e39e04e3
1 changed files with 3 additions and 13 deletions

View File

@ -46,17 +46,6 @@ abstract class Guess
*/ */
const LOW_CONFIDENCE = 0; const LOW_CONFIDENCE = 0;
/**
* The list of allowed confidence values
* @var array
*/
private static $confidences = array(
self::VERY_HIGH_CONFIDENCE,
self::HIGH_CONFIDENCE,
self::MEDIUM_CONFIDENCE,
self::LOW_CONFIDENCE,
);
/** /**
* The confidence about the correctness of the value * The confidence about the correctness of the value
* *
@ -101,8 +90,9 @@ abstract class Guess
*/ */
public function __construct($confidence) public function __construct($confidence)
{ {
if (!in_array($confidence, self::$confidences)) { if (self::VERY_HIGH_CONFIDENCE !== $confidence && self::HIGH_CONFIDENCE !== $confidence &&
throw new \InvalidArgumentException(sprintf('The confidence should be one of "%s"', implode('", "', self::$confidences))); self::MEDIUM_CONFIDENCE !== $confidence && self::LOW_CONFIDENCE !== $confidence) {
throw new \InvalidArgumentException('The confidence should be one of the constants defined in Guess.');
} }
$this->confidence = $confidence; $this->confidence = $confidence;