Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • Alnum
  • Alpha
  • Cp
  • Date
  • Digit
  • Email
  • Equal
  • Interval
  • Time
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * Pry Framework
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file LICENSE.txt.
10:  * 
11:  */
12: 
13: namespace Pry\Validate\Validator;
14: 
15: use Pry\Validate\ValidateAbstract;
16: 
17: /**
18:  * Validateur d'interval numérique. Inclusif
19:  * @category Pry
20:  * @package Validate
21:  * @subpackage Validate_Validator
22:  * @version 1.1.0 
23:  * @author Olivier ROGER <oroger.fr>
24:  * @todo Gestion inclusif/strict      
25:  *
26:  */
27: class Interval extends ValidateAbstract
28: {
29: 
30:     private $max;
31:     private $min;
32: 
33:     /**
34:      * Constructeur
35:      *
36:      * @param array $options
37:      * @access public
38:      */
39:     public function __construct(array $options)
40:     {
41:         if (!isset($options[0]) || !isset($options[1]))
42:         {
43:             throw new \InvalidArgumentException('Veuillez fournir les options d\'interval : array(12,24)');
44:         }
45:         $this->max      = max($options);
46:         $this->min      = min($options);
47:         $this->errorMsg = 'La valeur n\'est pas contenu dans l\'interval ' . $this->min . ' - ' . $this->max;
48:     }
49: 
50:     /**
51:      * Vérifie si $value est dans l'interval
52:      *
53:      * @param int $value
54:      * @access public
55:      * @return boolean
56:      */
57:     public function isValid($value)
58:     {
59:         if (is_numeric($value))
60:             if ($value >= $this->min && $value <= $this->max)
61:                 return true;
62:         return false;
63:     }
64: 
65: }
Pry API documentation generated by ApiGen 2.8.0