private function checkDiff(Statement $lhs, Statement $rhs) { $lhsSnak = $lhs->getMainSnak(); $rhsSnak = $rhs->getMainSnak(); if (!$lhsSnak instanceof PropertyValueSnak || !$rhsSnak instanceof PropertyValueSnak) { return true; } $diff = abs($lhsSnak->getDataValue()->getSortKey() - $rhsSnak->getDataValue()->getSortKey()); return $diff <= $this->diff->getSortKey(); }
/** * @see DataValueChecker::checkDataValue * * @param DataValue $dataValue * @return boolean * @throws InvalidArgumentException */ public function checkDataValue(DataValue $dataValue) { if (!$this->supportsDataValue($dataValue)) { throw new InvalidArgumentException('Only values of the same type as the boundaries are accepted.'); } $minKey = $this->minValue->getSortKey(); $maxKey = $this->maxValue->getSortKey(); $key = $dataValue->getSortKey(); return $minKey <= $key && $key <= $maxKey; }