src/Chippyash/Type/String/DigitType.php
protected function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }
        $value = (string) $value;

        if (!$this->hasPcreUnicodeSupport()) {
            // POSIX named classes are not supported, use alternative 0-9 match
            return preg_replace('/[^0-9]/', '', $value);
        }
        
        if (extension_loaded('mbstring')) {
            // Filter for the value with mbstring
            return preg_replace('/[^[:digit:]]/', '', $value);
        }
        
        // Filter for the value without mbstring
        return preg_replace('/[\p{^N}]/', '', $value);
    }
protected function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }
        $value = (string) $value;

        if (!$this->hasPcreUnicodeSupport()) {
            // POSIX named classes are not supported, use alternative 0-9 match
            return preg_replace('/[^0-9]/', '', $value);
        }
        
        if (extension_loaded('mbstring')) {
            // Filter for the value with mbstring
            return preg_replace('/[^[:digit:]]/', '', $value);
        }
        
        // Filter for the value without mbstring
        return preg_replace('/[\p{^N}]/', '', $value);
    }
protected function filter ( $ value ) { if ( ! is_scalar ( $ value ) ) { return $ value ; } $ value = ( string ) $ value ; if ( ! $ this -> hasPcreUnicodeSupport ( ) ) { // POSIX named classes are not supported, use alternative 0-9 match return preg_replace ( '/[^0-9]/' , '' , $ value ) ; } if ( extension_loaded ( 'mbstring' ) ) { // Filter for the value with mbstring return preg_replace ( '/[^[:digit:]]/' , '' , $ value ) ; } // Filter for the value without mbstring return preg_replace ( '/[\p{^N}]/' , '' , $ value ) ; }
Lifted entirely from the Zend framework so that we don't have to include
the Zend\Filter package and all its dependencies.

@param  string $value
@return string|mixed

zendframework/zend-filter/Zend/Filter/Digits.php
Zend Framework (http://framework.zend.com/)

@link      http://github.com/zendframework/zf2 for the canonical source repository
@copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
@license   http://framework.zend.com/license/new-bsd New BSD License
Defined by Zend\Filter\FilterInterface

Returns the string $value, removing all but digit characters

If the value provided is non-scalar, the value will remain unfiltered
Lifted entirely from the Zend framework so that we don t have to include the Zend \ Filter package and all its dependencies .