private function getLength($type = true)
    {
        if ($type) {
            $start = $this->getCharStart();
            $end = $this->getCharEnd();
        } else {
            $start = $this->getIndexStart();
            $end = $this->getIndexEnd();
        }

        if (is_null($start) && is_null($end)) {
            return;
        }

        if (!is_null($start) && is_null($end)) {
            return 1;
        }

        if ($start === $end) {
            return 1;
        }

        if ('#' === $start && '#' !== $end) {
            return $end + 1;
        }

        if ('#' !== $start && '#' === $end) {
            return;
        }

        $length = $end - $start + 1;

        if (1 > $length) {
            throw new InvalidMARCspecException(
                InvalidMARCspecException::PR.
                InvalidMARCspecException::NEGATIVE
            );
        }

        return $length;
    }