# PrimitiveNumber.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2006-2007 by Konstantin V. Arkhipov                     *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00016     abstract class PrimitiveNumber extends FiltrablePrimitive
    00017     {
    00018         abstract protected function checkNumber($number);
    00019         abstract protected function castNumber($number);
    00020
    00021         public function import($scope)
    00022         {
    00023             if (!BasePrimitive::import($scope))
    00024                 return null;
    00025
    00026             try {
    00027                 $this->checkNumber($scope[$this->name]);
    00028             } catch (WrongArgumentException $e) {
    00029                 return false;
    00030             }
    00031
    00032             $this->value = $this->castNumber($scope[$this->name]);
    00033
    00034             $this->selfFilter();
    00035
    00036             if (
    00037                 !(null !== $this->min && $this->value < $this->min)
    00038                 && !(null !== $this->max && $this->value > $this->max)
    00039             ) {
    00040                 return true;
    00041             } else {
    00042                 $this->value = null;
    00043             }
    00044
    00045             return false;
    00046         }
    00047     }
    00048 ?>