function it_doest_not_contain_keys_with_type_other_than_specified(Collection $internal)
 {
     $internal->containsKey(Argument::any())->shouldNotBeCalled();
     $internal->offsetExists(Argument::any())->shouldNotBeCalled();
     $this->containsKey('4')->shouldBe(false);
     $this->offsetExists('4')->shouldBe(false);
 }
 /**
  * {@inheritDoc}
  */
 public function offsetExists($offset)
 {
     $this->initialize();
     return $this->collection->offsetExists($offset);
 }
Esempio n. 3
0
 /**
  * Adds an element to collection preserving uniqueness of fields
  * @param Collection $collection
  * @param Entity $newItem
  * @param string $uniqueField
  * @return boolean true if added, false if already the same instance has been added
  * @throws \RuntimeException if element with the same unique field values exists
  */
 protected function addUnique(Collection $collection, Entity $newItem, $uniqueField = null)
 {
     if ($collection->contains($newItem)) {
         return false;
     }
     if (is_null($uniqueField)) {
         $collection->add($newItem);
     } else {
         $indexBy = $newItem->getProperty($uniqueField);
         if ($collection->offsetExists($indexBy)) {
             throw new \RuntimeException("Cannot add value '{$newItem}' to '{$this}': element by {$uniqueField}={$indexBy} already exists in the collection");
         }
         $collection->set($indexBy, $newItem);
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function offsetExists($offset)
 {
     return $this->inner->offsetExists($offset);
 }
Esempio n. 5
0
 /**
  * Whether the layout exists
  * @param string $media
  * @return boolean
  */
 public function hasLayout($media = TemplateLayout::MEDIA_SCREEN)
 {
     $has = $this->templateLayouts->offsetExists($media);
     return $has;
 }
 /**
  * Fills the data with the proper characteristic type.
  *
  * @param \Doctrine\Common\Collections\Collection $data
  * @param \Ekyna\Component\Characteristics\Schema\Definition $definition
  * @throws \InvalidArgumentException
  */
 private function appendProperData(Collection $data, Definition $definition)
 {
     $identifier = $definition->getIdentifier();
     if ($data->offsetExists($identifier)) {
         return;
     }
     $characteristic = $this->manager->createCharacteristicFromDefinition($definition);
     $data->set($identifier, $characteristic);
 }