* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Guess; use Symfony\Component\Form\Exception\InvalidArgumentException; /** * Base class for guesses made by TypeGuesserInterface implementation. * * Each instance contains a confidence value about the correctness of the guess. * Thus an instance with confidence HIGH_CONFIDENCE is more likely to be * correct than an instance with confidence LOW_CONFIDENCE. * * @author Bernhard Schussek */ abstract class Guess { /** * Marks an instance with a value that is extremely likely to be correct. */ const VERY_HIGH_CONFIDENCE = 3; /** * Marks an instance with a value that is very likely to be correct. */ const HIGH_CONFIDENCE = 2; /** * Marks an instance with a value that is likely to be correct. */ const MEDIUM_CONFIDENCE = 1; /** * Marks an instance with a value that may be correct. */ const LOW_CONFIDENCE = 0; /** * The confidence about the correctness of the value. * * One of VERY_HIGH_CONFIDENCE, HIGH_CONFIDENCE, MEDIUM_CONFIDENCE * and LOW_CONFIDENCE. * * @var int */ private $confidence; /** * Returns the guess most likely to be correct from a list of guesses. * * If there are multiple guesses with the same, highest confidence, the * returned guess is any of them. * * @param Guess[] $guesses An array of guesses * * @return self|null */ public static function getBestGuess(array $guesses) { $result = null; $maxConfidence = -1; foreach ($guesses as $guess) { if ($maxConfidence < $confidence = $guess->getConfidence()) { $maxConfidence = $confidence; $result = $guess; } } return $result; } /** * @param int $confidence The confidence * * @throws InvalidArgumentException if the given value of confidence is unknown */ public function __construct($confidence) { 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; } /** * Returns the confidence that the guessed value is correct. * * @return int One of the constants VERY_HIGH_CONFIDENCE, HIGH_CONFIDENCE, * MEDIUM_CONFIDENCE and LOW_CONFIDENCE */ public function getConfidence() { return $this->confidence; } } __halt_compiler();----SIGNATURE:----HigZiJ7LY0/poinWtwdymFG/nUnifuav1nPZvEpJh4r2RzcodAw/zjH+pJ9FUYRdK2N+P+vA0AwMGnR0G0Ua6f9uEnhCvf5QKihRl2POIE4FVQ/dHUP7GDqERdgb8oecE1n/KmVws7J7YAV7546DzCZo2nxKn0xxl2bFWUToPJjO1CRmNOjqusL/NyYBNmPSYEY8eStW9z2RHsWOFO0/9Y8yrNsiAopVYkYrQRv9A3JffV8cUUUxUkOTyYJLmgCr4DjUOqxPfoW0op2jPhGuKB5Xu5maplEBYe/Gc9NNkbAmcgMp/Q6RnZOZp58kPgIyqLBScvt0iu6YST2ja/uQUtYP/8TI/bTmMP10rqMSlvgYTOPzySLoCeUrCoastMVOOIcz2jBRf2ZuPVAcR3iCsvEMc+vD8mpjAVC0FQIYgPAE/v1sk+XpkT38OQCRN5m2Y0BTZOygSqoDRWGL9zD6cO745PCKrci7IlqDM8TGqWRH376R74AZgjYr42HSmQdkMc84+T8qlyFXgeUkYBQq0eRh+ARu2hLufpKZ2+cEPPqEqwuwJ3J3tl0LPqNbDQR47DGzLE5KfAuRO9emrukNYLnQuQJOvO5hY2coMWUalw8xAyoB8ZcQKTbXRWb5R1XxpZubcIM/Iyem43I3oaxh1AJ5l3N5Gfu1euAYrjRrmyU=----ATTACHMENT:----ODE4NDk0NTI1NzQ5MDkyNSAxNzQ1MTYwMjYyOTA0Mzc4IDUwMzc2NDEzNTE5NjcxNTc=