src/Common/TimeExpression.php
protected function decodeRegexString(): bool
    {
        $regex_string = '#([0-9]+)[\s]*('.implode('|', array_keys($this->tokensValues)).'){1}#i';
        $regex_clock_string = '#^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$#i';

        if (preg_match_all($regex_string, $this->expression, $matches)) {
            foreach ($matches[1] as $index => $value) {
                $this->time += $this->tokensValues[$matches[2][$index]] * $value;
            }
            $this->di = DateInterval::createFromDateString($this->integerToString($this->time));
            return true;
        } elseif (preg_match_all($regex_clock_string, $this->expression, $matches) && count($matches) == 4) {
            if (!empty($matches[1][0])) {
                $this->time += (int)$matches[1][0] * 3600;
            }
            if (!empty($matches[2][0])) {
                $this->time += (int)$matches[2][0] * 60;
            }
            if (!empty($matches[3][0])) {
                $this->time += (int)$matches[3][0];
            }
            $this->di = DateInterval::createFromDateString($this->integerToString($this->time));
            return true;
        }

        return false;
    }
protected function decodeRegexString(): bool
    {
        $regex_string = '#([0-9]+)[\s]*('.implode('|', array_keys($this->tokensValues)).'){1}#i';
        $regex_clock_string = '#^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$#i';

        if (preg_match_all($regex_string, $this->expression, $matches)) {
            foreach ($matches[1] as $index => $value) {
                $this->time += $this->tokensValues[$matches[2][$index]] * $value;
            }
            $this->di = DateInterval::createFromDateString($this->integerToString($this->time));
            return true;
        } elseif (preg_match_all($regex_clock_string, $this->expression, $matches) && count($matches) == 4) {
            if (!empty($matches[1][0])) {
                $this->time += (int)$matches[1][0] * 3600;
            }
            if (!empty($matches[2][0])) {
                $this->time += (int)$matches[2][0] * 60;
            }
            if (!empty($matches[3][0])) {
                $this->time += (int)$matches[3][0];
            }
            $this->di = DateInterval::createFromDateString($this->integerToString($this->time));
            return true;
        }

        return false;
    }
protected function decodeRegexString ( ) : bool { $ regex_string = '#([0-9]+)[\s]*(' . implode ( '|' , array_keys ( $ this -> tokensValues ) ) . '){1}#i' ; $ regex_clock_string = '#^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$#i' ; if ( preg_match_all ( $ regex_string , $ this -> expression , $ matches ) ) { foreach ( $ matches [ 1 ] as $ index => $ value ) { $ this -> time += $ this -> tokensValues [ $ matches [ 2 ] [ $ index ] ] * $ value ; } $ this -> di = DateInterval :: createFromDateString ( $ this -> integerToString ( $ this -> time ) ) ; return true ; } elseif ( preg_match_all ( $ regex_clock_string , $ this -> expression , $ matches ) && count ( $ matches ) == 4 ) { if ( ! empty ( $ matches [ 1 ] [ 0 ] ) ) { $ this -> time += ( int ) $ matches [ 1 ] [ 0 ] * 3600 ; } if ( ! empty ( $ matches [ 2 ] [ 0 ] ) ) { $ this -> time += ( int ) $ matches [ 2 ] [ 0 ] * 60 ; } if ( ! empty ( $ matches [ 3 ] [ 0 ] ) ) { $ this -> time += ( int ) $ matches [ 3 ] [ 0 ] ; } $ this -> di = DateInterval :: createFromDateString ( $ this -> integerToString ( $ this -> time ) ) ; return true ; } return false ; }
Decode string with customs regex formats

@return bool
Decode string with customs regex formats