http://phing.info/

Source Code Coverage

Designed for use with PHPUnit2, Xdebug and Phing.

Methods: 1 LOC: 53 Statements: 12
Legend: executednot executeddead code
Source file Statements Methods Total coverage
Int.php 100.0% 100.0% 100.0%
 
1
<?php
2
/**
3
 * Xyster Framework
4
 *
5
 * This source file is subject to the new BSD license that is bundled
6
 * with this package in the file LICENSE.txt.
7
 * It is also available through the world-wide-web at this URL:
8
 * http://www.opensource.org/licenses/bsd-license.php
9
 *
10
 * @category  Xyster
11
 * @package   Xyster_Validate
12
 * @copyright Copyright LibreWorks, LLC (http://libreworks.net)
13
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
14
 * @version   $Id: Uri.php 190 2008-01-07 22:39:57Z doublecompile $
15
 */
16
namespace Xyster\Validate;
17
/**
18
 * An integer validator
19
 *
20
 * @category  Xyster
21
 * @package   Xyster_Validate
22
 * @copyright Copyright LibreWorks, LLC (http://libreworks.net)
23
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
24
 */
25
class Int extends \Zend_Validate_Int
26 1
{
27
    /**
28
     * Defined by Zend_Validate_Interface
29
     *
30
     * Returns true if and only if $value is a valid integer
31
     *
32
     * @param  string $value
33
     * @return boolean
34
     */
35
    public function isValid($value)
36
    {
37 1
        $valueString = (string) $value;
38
39 1
        $this->_setValue($valueString);
40
41 1
        $locale = localeconv();
42
43 1
        $valueFiltered = str_replace($locale['decimal_point'], '.', $valueString);
44 1
        $valueFiltered = str_replace($locale['thousands_sep'], '', $valueFiltered);
45
46 1
        if ( !preg_match( '/^([0-9]+)(\.[0-9]+)?$/', $valueFiltered ) ) {
47 1
            $this->_error(self::NOT_INT);
48 1
            return false;
49
        }
50
51 1
        return true;
52
    }
53 1
}


Report generated at 2010-10-18T17:19:48-04:00