Hoa central
Integer.php
Go to the documentation of this file.
1 <?php
2 
46 import('Filter.Abstract');
47 
63 
69  const KEEP = 0;
70 
76  const CAST = 1;
77 
83  protected $arguments = array(
84  'operation' => 'specify the type of operation : KEEP (0) or CAST (1).'
85  );
86 
87 
88 
96  public function filter ( $string = null ) {
97 
98  if($this->getFilterArgument('operation') == self::CAST)
99  return (int) (string) $string;
100 
101  elseif($this->getFilterArgument('operation') == self::KEEP)
102  return preg_replace('#[^[:digit:]]#', '', (string) $string);
103 
104  return null;
105  }
106 }
getFilterArgument($name)
Definition: Abstract.php:146
filter($string=null)
Definition: Integer.php:96