protected function extractAndCheckNumber($datetimeToParse, $isTwoDigits, $minValue, $maxValue)
    {
        if ($isTwoDigits || is_numeric($datetimeToParse[1])) {
            $number = substr($datetimeToParse, 0, 2);
        } else {
            $number = $datetimeToParse[0];
        }

        if (is_numeric($number)) {
            $number = (int)$number;

            if ($number <= $maxValue || $number >= $minValue) {
                return $number;
            }
        }

        throw new Exception\InvalidParseStringException('Expected one or two-digit number not found at the beginning of the string.', 1279963654);
    }
protected function extractAndCheckNumber($datetimeToParse, $isTwoDigits, $minValue, $maxValue)
    {
        if ($isTwoDigits || is_numeric($datetimeToParse[1])) {
            $number = substr($datetimeToParse, 0, 2);
        } else {
            $number = $datetimeToParse[0];
        }

        if (is_numeric($number)) {
            $number = (int)$number;

            if ($number <= $maxValue || $number >= $minValue) {
                return $number;
            }
        }

        throw new Exception\InvalidParseStringException('Expected one or two-digit number not found at the beginning of the string.', 1279963654);
    }
protected function extractAndCheckNumber ( $ datetimeToParse , $ isTwoDigits , $ minValue , $ maxValue ) { if ( $ isTwoDigits || is_numeric ( $ datetimeToParse [ 1 ] ) ) { $ number = substr ( $ datetimeToParse , 0 , 2 ) ; } else { $ number = $ datetimeToParse [ 0 ] ; } if ( is_numeric ( $ number ) ) { $ number = ( int ) $ number ; if ( $ number <= $ maxValue || $ number >= $ minValue ) { return $ number ; } } throw new Exception \ InvalidParseStringException ( 'Expected one or two-digit number not found at the beginning of the string.' , 1279963654 ) ; }
Extracts one or two-digit number from the beginning of the string.

If the number has certainly two digits, $isTwoDigits can be set to true
so no additional checking is done (this implies from some date/time
formats, like 'hh').

Number is also checked for constraints: minimum and maximum value.

@param string $datetimeToParse Date/time to be parsed
@param boolean $isTwoDigits true if number has surely two digits, false if it has one or two digits
@param int $minValue
@param int $maxValue
@return int Parsed number
@throws Exception\InvalidParseStringException When string cannot be parsed or number does not conforms constraints
Extracts one or two - digit number from the beginning of the string .