Control = $control; $this->options = &$control->Option->options; } /** * Runs all numeric operations * * @param (string) str: Unit string */ public function numeric( $str ) { $str = $this->decimal( $str ); $str = $this->zeroes( $str ); $str = $this->units( $str ); return $str; } /** * Remove's unecessary decimal, ie 13.0px => 13px * * @param (string) str: Unit string */ private function decimal( $str ) { if ( preg_match( $this->rdecimal, $str, $match ) ) { $str = ( $match[ 1 ] == '-' ? '-' : '' ) . floatval( $match[ 2 ] ) . $match[ 3 ]; } return $str; } /** * Removes suffix from 0 unit, ie 0px; => 0; * * @param (string) str: Unit string */ private function units( $str ) { if ( preg_match( $this->runit, $str, $match ) ) { $str = '0'; } return $str; } /** * Removes leading zero in decimal, ie 0.33px => .33px * * @param (string) str: Unit string */ private function zeroes( $str ) { if ( preg_match( $this->rzero, $str, $match ) ) { $str = ( isset( $match[ 1 ] ) && $match[ 1 ] == '-' ? '-' : '' ) . $match[ 2 ] . ( isset( $match[ 3 ] ) ? $match[ 3 ] : '' ); } return $str; } /** * Access to private methods for testing * * @param (string) method: Method to be called * @param (array) args: Array of paramters to be passed in */ public function access( $method, $args ) { if ( method_exists( $this, $method ) ) { return call_user_func_array( array( $this, $method ), $args ); } else { throw new CSSCompression_Exception( "Unknown method in Numeric Class - " . $method ); } } }; ?>