8000 [Form] replaced UnexpectedValueException by InvalidArgumentException in Guess by Tobion · Pull Request #5361 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] replaced UnexpectedValueException by InvalidArgumentException in Guess #5361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 29, 2012
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Form] refactor Guess
  • Loading branch information
Tobion committed Aug 28, 2012
commit e7e39e04e3d476dc8968d6d01d4f192a44c6668c
16 changes: 3 additions & 13 deletions src/Symfony/Component/Form/Guess/Guess.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ abstract class Guess
*/
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
*
Expand Down Expand Up @@ -101,8 +90,9 @@ public static function getBestGuess(array $guesses)
*/
public function __construct($confidence)
{
if (!in_array($confidence, self::$confidences)) {
throw new \InvalidArgumentException(sprintf('The confidence should be one of "%s"', implode('", "', self::$confidences)));
if (self::VERY_HIGH_CONFIDENCE !== $confidence && self::HIGH_CONFIDENCE !== $confidence &&
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;
Expand Down
0