src/Range.php
/**
     * Compares the boundary points of this Range with another Range.
     *
     * @see https://dom.spec.whatwg.org/#dom-range-compareboundarypoints
     *
     * @param int               $how         A constant describing how the two Ranges should be compared. Possible
     *                                       values:
     *
     *                                       Range::END_TO_END     - Compares the end boundary points of both Ranges.
     *                                       Range::END_TO_START   - Compares the end boudary point of $sourceRange to
     *                                                               the start boundary point of this Range.
     *                                       Range::START_TO_END   - Compares the start boundary point of $sourceRange
     *                                                               to the end boundary of this Range.
     *                                       Range::START_TO_START - Compares the start boundary point of $sourceRange
     *                                                               to the start boundary of this Range.
     *
     * @param \Rowbot\DOM\Range $sourceRange A Range whose boundary points are to be compared.
     *
     * @return int Returns -1, 0, or 1 indicating wether the Range's boundary points are before, equal, or after
     *             $sourceRange's boundary points, respectively.
     *
     * @throws \Rowbot\DOM\Exception\NotSupportedError
     * @throws \Rowbot\DOM\Exception\WrongDocumentError
     */
Compares the boundary points of this Range with another Range.

@param int               $how         A constant describing how the two Ranges should be compared. Possible
values.

:END_TO_END     - Compares the end boundary points of both Ranges.
Range::END_TO_START   - Compares the end boudary point of $sourceRange to
the start boundary point of this Range.
Range::START_TO_END   - Compares the start boundary point of $sourceRange
to the end boundary of this Range.
Range::START_TO_START - Compares the start boundary point of $sourceRange
to the start boundary of this Range.

@param \Rowbot\DOM\Range $sourceRange A Range whose boundary points are to be compared.

@return int Returns -1, 0, or 1 indicating wether the Range's boundary points are before, equal, or after
$sourceRange's boundary points, respectively.


Compares the boundary points of this Range with another Range . @param int $how A constant describing how the two Ranges should be compared . Possible values . : END_TO_END - Compares the end boundary points of both Ranges . Range :: END_TO_START - Compares the end boudary point of $sourceRange to the start boundary point of this Range . Range :: START_TO_END - Compares the start boundary point of $sourceRange to the end boundary of this Range . Range :: START_TO_START - Compares the start boundary point of $sourceRange to the start boundary of this Range . @param \ Rowbot \ DOM \ Range $sourceRange A Range whose boundary points are to be compared . @return int Returns - 1 0 or 1 indicating wether the Range ' s boundary points are before equal or after $sourceRange ' s boundary points respectively .
public function compareBoundaryPoints(int $how, self $sourceRange): int
    {
        if ($how < self::START_TO_START || $how > self::END_TO_START) {
            throw new NotSupportedError();
        }
        $sourceRangeRoot = $sourceRange->startNode->getRootNode();
        if ($this->startNode->getRootNode() !== $sourceRangeRoot) {
            throw new WrongDocumentError();
        }
        switch ($how) {
            case self::START_TO_START:
                $thisPoint = [$this->startNode, $this->startOffset];
                $otherPoint = [$sourceRange->startNode, $sourceRange->startOffset];
                break;
            case self::START_TO_END:
                $thisPoint = [$this->endNode, $this->endOffset];
                $otherPoint = [$sourceRange->startNode, $sourceRange->startOffset];
                break;
            case self::END_TO_END:
                $thisPoint = [$this->endNode, $this->endOffset];
                $otherPoint = [$sourceRange->endNode, $sourceRange->endOffset];
                break;
            case self::END_TO_START:
                $thisPoint = [$this->startNode, $this->startOffset];
                $otherPoint = [$sourceRange->endNode, $sourceRange->endOffset];
                break;
        }
        switch ($this->computePosition($thisPoint, $otherPoint)) {
            case 'before':
                return -1;
            case 'equal':
                return 0;
            case 'after':
                return 1;
        }
    }
public function compareBoundaryPoints ( int $ how , self $ sourceRange ) : int { if ( $ how < self :: START_TO_START || $ how > self :: END_TO_START ) { throw new NotSupportedError ( ) ; } $ sourceRangeRoot = $ sourceRange -> startNode -> getRootNode ( ) ; if ( $ this -> startNode -> getRootNode ( ) !== $ sourceRangeRoot ) { throw new WrongDocumentError ( ) ; } switch ( $ how ) { case self :: START_TO_START : $ thisPoint = [ $ this -> startNode , $ this -> startOffset ] ; $ otherPoint = [ $ sourceRange -> startNode , $ sourceRange -> startOffset ] ; break ; case self :: START_TO_END : $ thisPoint = [ $ this -> endNode , $ this -> endOffset ] ; $ otherPoint = [ $ sourceRange -> startNode , $ sourceRange -> startOffset ] ; break ; case self :: END_TO_END : $ thisPoint = [ $ this -> endNode , $ this -> endOffset ] ; $ otherPoint = [ $ sourceRange -> endNode , $ sourceRange -> endOffset ] ; break ; case self :: END_TO_START : $ thisPoint = [ $ this -> startNode , $ this -> startOffset ] ; $ otherPoint = [ $ sourceRange -> endNode , $ sourceRange -> endOffset ] ; break ; } switch ( $ this -> computePosition ( $ thisPoint , $ otherPoint ) ) { case 'before' : return - 1 ; case 'equal' : return 0 ; case 'after' : return 1 ; } }
Compares the boundary points of this Range with another Range.
Compares the boundary points of this Range with another Range .