Esempio n. 1
0
 /**
  * Get related entity attribute
  *
  * @return Attribute
  * @throws UnknownAttributeException
  */
 public function getEntityAttribute()
 {
     if (!$this->attributes->containsKey($this->entityAttributeName)) {
         throw new UnknownAttributeException('There is no entity attribute');
     }
     return $this->attributes->get($this->entityAttributeName);
 }
 private function getCalculator(ShippingMethodInterface $shippingMethod) : ShippingCalculatorInterface
 {
     $calculator = $shippingMethod->getCalculator();
     if (false === $this->calculators->containsKey($calculator)) {
         throw new CalculatorNotFoundException($calculator);
     }
     return $this->calculators->get($calculator);
 }
Esempio n. 3
0
 /**
  * Remove a product from the basket.
  *
  * @param Product $product
  * @param int     $nb
  *
  * @return $this
  */
 public function removeProduct(Product $product, $nb = 1)
 {
     if ($this->products->containsKey($product->getId())) {
         $this->decreaseNbProduct($product, $nb);
         $nbLeft = $this->getNbProduct($product);
         if (0 >= $nbLeft) {
             $this->products->remove($product->getId());
         }
     }
     return $this;
 }
Esempio n. 4
0
 /**
  * @param TranslationInterface $translation
  */
 public function addTranslation(TranslationInterface $translation)
 {
     if (!$this->translations->containsKey($translation->getLocale())) {
         $this->translations->set($translation->getLocale(), $translation);
         $translation->setTranslatable($this);
     }
 }
 public function getType(string $type) : TypeInterface
 {
     if (false === $this->types->containsKey($type)) {
         throw new TypeNotFoundException($type, $this->types->getKeys());
     }
     return $this->types->get($type);
 }
 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);
 }
Esempio n. 7
0
 /**
  * @param int $index
  * @return \Kdyby\Doctrine\Forms\EntityContainer
  */
 private function createNewContainer($index)
 {
     if (!$this->collection->containsKey($index)) {
         $this->collection->set($index, $this->createNewEntity());
     }
     $class = $this->containerClass;
     return new $class($this->collection->get($index));
 }
Esempio n. 8
0
 /**
  * {@inheritdoc}
  */
 public function reorderChildren($order)
 {
     if (count($order) != $this->count()) {
         throw new \InvalidArgumentException('Cannot reorder children, order does not contain all children.');
     }
     $newChildren = array();
     foreach ($order as $name) {
         if (!$this->children->containsKey($name)) {
             throw new \InvalidArgumentException('Cannot find children named ' . $name);
         }
         $child = $this->getChild($name);
         $newChildren[$name] = $child;
     }
     $this->setChildren($newChildren);
     return $this;
 }
Esempio n. 9
0
 public function hasModifier(string $name) : bool
 {
     return $this->modifiers->containsKey($name);
 }
Esempio n. 10
0
 public function hasCelestialBody($number)
 {
     return $this->celestialBodies->containsKey($number);
 }
 /**
  * {@inheritdoc}
  */
 public function containsKey($key)
 {
     $this->initialize();
     return $this->coll->containsKey($key);
 }
Esempio n. 12
0
 public function hasGalaxy($number)
 {
     return $this->galaxies->containsKey($number);
 }
 public function testContainsKey()
 {
     $this->_coll[5] = 'five';
     $this->assertTrue($this->_coll->containsKey(5));
 }
Esempio n. 14
0
 /**
  * Adds a permission to the merged permissions Collection.
  * Override logic is handled from outside to enable strict or standard permissions.
  *
  * @param Permission $permission
  * @param bool       $override
  */
 protected function add(Permission $permission, $override = true)
 {
     if ($override || !$this->permissions->containsKey($permission->getName())) {
         $this->permissions->set($permission->getName(), $permission);
     }
 }
Esempio n. 15
0
 /**
  * @dataProvider provideCollection
  */
 public function testContainsKey(Collection $coll, array $elements)
 {
     $keys = array_keys($elements);
     $this->assertTrue($coll->containsKey(current($keys)));
     $this->assertTrue($coll->containsKey(end($keys)));
     $this->assertFalse($coll->containsKey('this-will-surely-not-exist'));
 }
 /**
  * {@inheritdoc}
  */
 public function containsKey($key)
 {
     if (!$this->initialized && $this->association['fetch'] === Mapping\ClassMetadataInfo::FETCH_EXTRA_LAZY && isset($this->association['indexBy'])) {
         $persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association);
         return $this->coll->containsKey($key) || $persister->containsKey($this, $key);
     }
     $this->initialize();
     return $this->coll->containsKey($key);
 }
 /**
  * {@inheritdoc}
  */
 public function containsKey($key)
 {
     return $this->inner->containsKey($key);
 }
Esempio n. 18
0
 public function hasSystem($number)
 {
     return $this->systems->containsKey($number);
 }
Esempio n. 19
0
 public function testCanVerifyExistingKeysWithNullValues()
 {
     $this->_coll->set('key', null);
     $this->assertTrue($this->_coll->containsKey('key'));
 }
Esempio n. 20
0
 /**
  * @param FileProperty $fileProperty
  */
 public function addCustomProperty(FileProperty $fileProperty)
 {
     $name = $fileProperty->getName();
     if ($this->properties->containsKey($name)) {
         // non unique exception
         throw new \RuntimeException("Property with name {$name} already exists in collection");
     }
 }