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;
    }
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;
    }
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 ; }
Calculate the length of charrange or index range.

@param bool $type True for charrange and false for indexrange

@throws CK\MARCspec\Exception\InvalidMARCspecException

@return int $length
Calculate the length of charrange or index range .