Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function evaluate($value)
 {
     $geolocalizable = $this->selector->apply($value);
     if (!$geolocalizable instanceof GeolocalizableInterface) {
         throw new \LogicException(\sprintf('%s not implement %s, the near operator is defined only to %s instances', \is_object($geolocalizable) ? \gettype($geolocalizable) : \get_class($geolocalizable), GeolocalizableInterface::class, GeolocalizableInterface::class));
     }
     return $geolocalizable->coordinate() !== null && $geolocalizable->coordinate()->distance($this->coordinate())->compareTo($this->radius()) <= 0;
 }
Exemple #2
0
 /**
  * @param SelectorInterface $value
  *
  * @throws \LogicException
  *
  * @return mixed
  */
 protected function createValue(SelectorInterface $value)
 {
     if ($value instanceof Value) {
         $actualValue = $value->value();
         if ($actualValue instanceof EntityInterface) {
             return $actualValue->id();
         }
         if ($actualValue instanceof NativeValueObjectInterface) {
             return $actualValue->toNative();
         }
         return $actualValue;
     }
     throw new \LogicException(\sprintf('The %s selector cannot be used as a value selector', \get_class($value)));
 }
 /**
  * @param SelectorInterface $selector
  *
  * @return $this
  */
 public function select(SelectorInterface $selector)
 {
     $this->addCurrentSelector();
     $this->currentSelector = $selector instanceof Selectors ? $selector->selector() : $selector;
     return $this;
 }