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; }
/** * {@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; }
/** * {@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; }
/** * 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); }); }