本文整理汇总了PHP中Doctrine\Common\Collections\Collection::containsKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::containsKey方法的具体用法?PHP Collection::containsKey怎么用?PHP Collection::containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\Collection
的用法示例。
在下文中一共展示了Collection::containsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEntityAttribute
/**
* 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);
}
示例2: getCalculator
private function getCalculator(ShippingMethodInterface $shippingMethod) : ShippingCalculatorInterface
{
$calculator = $shippingMethod->getCalculator();
if (false === $this->calculators->containsKey($calculator)) {
throw new CalculatorNotFoundException($calculator);
}
return $this->calculators->get($calculator);
}
示例3: removeProduct
/**
* 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;
}
示例4: addTranslation
/**
* @param TranslationInterface $translation
*/
public function addTranslation(TranslationInterface $translation)
{
if (!$this->translations->containsKey($translation->getLocale())) {
$this->translations->set($translation->getLocale(), $translation);
$translation->setTranslatable($this);
}
}
示例5: getType
public function getType(string $type) : TypeInterface
{
if (false === $this->types->containsKey($type)) {
throw new TypeNotFoundException($type, $this->types->getKeys());
}
return $this->types->get($type);
}
示例6:
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);
}
示例7: createNewContainer
/**
* @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));
}
示例8: reorderChildren
/**
* {@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;
}
示例9: hasModifier
public function hasModifier(string $name) : bool
{
return $this->modifiers->containsKey($name);
}
示例10: hasCelestialBody
public function hasCelestialBody($number)
{
return $this->celestialBodies->containsKey($number);
}
示例11: containsKey
/**
* {@inheritdoc}
*/
public function containsKey($key)
{
$this->initialize();
return $this->coll->containsKey($key);
}
示例12: hasGalaxy
public function hasGalaxy($number)
{
return $this->galaxies->containsKey($number);
}
示例13: testContainsKey
public function testContainsKey()
{
$this->_coll[5] = 'five';
$this->assertTrue($this->_coll->containsKey(5));
}
示例14: add
/**
* 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);
}
}
示例15: testContainsKey
/**
* @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'));
}