/** * @dataProvider instanceProvider * * @since 1.0 * * @param ValueDescription $description */ public function testGetComparator(ValueDescription $description) { $comparator = $description->getComparator(); $this->assertInternalType('integer', $comparator); $newInstance = new ValueDescription($description->getValue(), $comparator); $this->assertEquals($comparator, $newInstance->getComparator(), 'Comparator is returned as it was passed to the constructor'); }
private function buildQueryForValueDescription(ValueDescription $valueDescription, Expr $expr, PropertyId $currentProperty = null) { $value = $valueDescription->getValue(); switch ($valueDescription->getComparator()) { case ValueDescription::COMP_EQUAL: case ValueDescription::COMP_LIKE: $expr->field('sclaims.' . $value->getType())->equals($this->buildPropertyValueForSearch($currentProperty, $value)); return $expr; default: throw new FeatureNotSupportedException('Unsupported ValueDescription comparator'); } }
private function buildQueryForValueDescription(ValueDescription $valueDescription, PropertyId $propertyId = null) { if ($propertyId === null) { throw new FeatureNotSupportedException('Search of value on any properties is not supported'); } if (!in_array($valueDescription->getComparator(), [ValueDescription::COMP_EQUAL, ValueDescription::COMP_LIKE])) { throw new FeatureNotSupportedException('Unsupported ValueDescription comparator'); } $dataValue = $valueDescription->getValue(); if ($dataValue instanceof EntityIdValue) { return $this->buildEntityIdValueForSearch($dataValue, $propertyId); } elseif ($dataValue instanceof StringValue) { return new StringQuery($propertyId, $dataValue); } elseif ($dataValue instanceof TimeValue) { return new BetweenQuery($propertyId, $dataValue, $dataValue); } else { throw new FeatureNotSupportedException('Not supported DataValue type: ' . $dataValue->getType()); } }