src/helpers/MeasureHelper.php
public static function parseString($source, $matchRules)
    {
        foreach ((array) $matchRules as $matchRule) {
            if (is_callable($matchRule) === true) {
                return call_user_func($matchRule, $source);
            } else {
                if (preg_match($matchRule, $source, $matches) === 1) {
                    $value = $matches['integral'];
                    if (isset($matches['fractional'])) {
                        $value .= '.' . $matches['fractional'];
                    }
                    return (double) $value;
                }
            }
        }
        return false;
    }
public static function parseString($source, $matchRules)
    {
        foreach ((array) $matchRules as $matchRule) {
            if (is_callable($matchRule) === true) {
                return call_user_func($matchRule, $source);
            } else {
                if (preg_match($matchRule, $source, $matches) === 1) {
                    $value = $matches['integral'];
                    if (isset($matches['fractional'])) {
                        $value .= '.' . $matches['fractional'];
                    }
                    return (double) $value;
                }
            }
        }
        return false;
    }
public static function parseString ( $ source , $ matchRules ) { foreach ( ( array ) $ matchRules as $ matchRule ) { if ( is_callable ( $ matchRule ) === true ) { return call_user_func ( $ matchRule , $ source ) ; } else { if ( preg_match ( $ matchRule , $ source , $ matches ) === 1 ) { $ value = $ matches [ 'integral' ] ; if ( isset ( $ matches [ 'fractional' ] ) ) { $ value .= '.' . $ matches [ 'fractional' ] ; } return ( double ) $ value ; } } } return false ; }
Parse string by regexp or closure.
@param string $source
@param \Closure[]|string[]|\Closure|string $matchRules
@return false|float
Parse string by regexp or closure .