Пример #1
0
 private function addProperties(Query $query, string $name, MapInterface $mapping) : Query
 {
     if ($mapping->contains($name)) {
         $query = $query->withProperties($mapping->get($name)->get(0)->toPrimitive())->withParameters($mapping->get($name)->get(1)->toPrimitive());
     }
     return $query;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public static function fromConfig(MapInterface $config, Types $types) : TypeInterface
 {
     if ((string) $config->keyType() !== 'scalar' || (string) $config->valueType() !== 'variable') {
         throw new InvalidArgumentException();
     }
     $type = new self();
     if ($config->contains('format')) {
         $type->format = (string) $config->get('format');
     }
     return $type;
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 public function equals(MapInterface $map)
 {
     if ($this->size() !== $map->size()) {
         return FALSE;
     }
     foreach ($this->data as $key => $value) {
         if (!$map->contains($key, $value)) {
             return FALSE;
         }
     }
     return TRUE;
 }
Пример #4
0
 /**
  * Build a collection with only the elements that are properties
  *
  * @param CollectionInterface $changeset
  * @param MapInterface<string, Property> $properties
  *
  * @return CollectionInterface
  */
 private function buildProperties(CollectionInterface $changeset, MapInterface $properties) : CollectionInterface
 {
     return $changeset->filter(function ($data, string $property) use($properties) {
         return $properties->contains($property);
     });
 }