public static function findStubLength(
        $file,
        $pattern = self::PATTERN_OPEN
    ) {
        if (!($fp = fopen($file, 'rb'))) {
            throw new RuntimeException(
                sprintf(
                    'The phar "%s" could not be opened for reading.',
                    $file
                )
            );
        }

        $stub = null;
        $offset = 0;
        $combo = str_split($pattern);

        while (!feof($fp)) {
            if (fgetc($fp) === $combo[$offset]) {
                $offset++;

                if (!isset($combo[$offset])) {
                    $stub = ftell($fp);

                    break;
                }
            } else {
                $offset = 0;
            }
        }

        fclose($fp);

        if (null === $stub) {
            throw new InvalidArgumentException(
                sprintf(
                    'The pattern could not be found in "%s".',
                    $file
                )
            );
        }

        return $stub;
    }