public function testHasProperty() { $collection = new CAttributeCollection(); $this->assertEquals(false, $collection->hasProperty('Property')); $collection->Property = 'value'; $this->assertEquals(true, $collection->hasProperty('Property')); }
/** * Gets the solr client options * @return CAttributeCollection the client options */ public function getClientOptions() { if ($this->_clientOptions === null) { $clientOptions = new CAttributeCollection(); $clientOptions->caseSensitive = true; if ($this->_client !== null) { foreach ($this->_client->getOptions() as $key => $value) { $clientOptions->add($key, $value); } } $this->_clientOptions = $clientOptions; } return $this->_clientOptions; }
public function itemAt($key) { if ($this->contains($key)) { return parent::itemAt($key); } return null; }
/** * Gets the exchange with the given name, or creates it if it doesn't exist. * @param string $key the name of the exchange * * @return Exchange the exchange instance */ public function itemAt($key) { $item = parent::itemAt($key); if ($item === null) { $item = $this->createExchange($key); $this->add($key, $item); } return $item; }
/** * @inheritDoc */ public function add($key, $value) { if (!$value instanceof Queue) { $value = $this->createQueue($key, $value); } else { $value->name = $key; $value->setClient($this->getClient()); } parent::add($key, $value); }
/** * Overrides the parent to load resources from the api on demand. * * @inheritDoc */ public function itemAt($key) { $item = parent::itemAt($key); if ($item === null && !in_array($key, $this->_lookedUpResourceNames)) { $resource = $this->lookupResource($key); if ($resource) { $this->add($key, $resource); return $resource; } } return $item; }
/** * @param \Restyii\Client\Schema\Attribute[] $attributes */ public function setAttributes($attributes) { foreach ($attributes as $name => $attribute) { if (!$attribute instanceof Attribute) { $attributes[$name] = new Attribute($attribute); $attributes[$name]->name = $name; } } if (!$attributes instanceof \CAttributeCollection) { $c = new \CAttributeCollection(); $c->caseSensitive = true; $c->copyFrom($attributes); $attributes = $c; } $this->_attributes = $attributes; }
public function testMergeWithCaseInSensitive() { $collection = new CAttributeCollection(); $collection->caseSensitive = true; $collection->add('k1', 'item'); $item = array('K1' => 'ITEM'); $collection->mergeWith($item); $this->assertEquals('item', $collection->itemAt('k1')); $this->assertEquals('ITEM', $collection->itemAt('K1')); }
/** * Unsets the element at the specified offset. * This method is required by the interface ArrayAccess. * @param mixed $offset the offset to unset element */ public function offsetUnset($offset) { $this->_attributes->remove($offset); }
/** * Sets the parameters for the action * @param \Restyii\Client\Schema\Parameter[] $params */ public function setParams($params) { foreach ($params as $name => $param) { if (!$param instanceof Parameter) { $params[$name] = new Parameter($param); $params[$name]->name = $name; } } if (!$params instanceof \CAttributeCollection) { $c = new \CAttributeCollection(); $c->caseSensitive = true; $c->copyFrom($params); $params = $c; } $this->_params = $params; }