offsetGet() public method

Get an item at a given offset.
public offsetGet ( mixed $key ) : mixed
$key mixed
return mixed
 /**
  * @param  mixed $key
  * @return ServiceInterface
  * @throws ServiceNotFoundInCollectionException
  */
 public function offsetGet($key)
 {
     if (!isset($this->items[$key])) {
         throw new ServiceNotFoundInCollectionException("Service with key '{$key}' not found in collection");
     }
     return parent::offsetGet($key);
 }
Example #2
0
 /**
  * @param $type
  * @return IJobHandler
  * @throws HandlerException
  */
 public function getHandlerForType($type)
 {
     if ($this->hasHandlerForType($type)) {
         return $this->handlers->offsetGet($type);
     }
     throw new HandlerException("No handler of type {$type} exists.");
 }
Example #3
0
 /**
  * Get defaults settings.
  *
  * @param string|null $key A setting key (optional)
  *
  * @return array
  *
  * @throws \Subbly\Api\Service\Exception
  *
  * @api
  */
 public function defaults($key = null)
 {
     if (is_string($key)) {
         if (!$this->has($key)) {
             throw new Exception(sprintf(Exception::SETTING_KEY_NOT_EXISTS, $key));
         }
         return $this->defaults->offsetGet($key);
     }
     return $this->defaults->toArray();
 }
Example #4
0
 public function offsetUnset($key)
 {
     $keySegments = explode('.', $key);
     $firstKeySegment = array_shift($keySegments);
     if ($keySegments && $this->offsetExists($firstKeySegment)) {
         return parent::offsetGet($firstKeySegment)->items()->offsetUnset(implode('.', $keySegments));
     } else {
         return parent::offsetUnset($key);
     }
 }
Example #5
0
 /**
  * @expectedException PHPUnit_Framework_Error_Notice
  */
 public function testArrayAccessOffsetGetOnNonExist()
 {
     $c = new Collection(['foo', 'bar']);
     $c->offsetGet(1000);
 }
Example #6
0
 /**
  * @param mixed $offset
  * @return Record|null
  */
 public function offsetGet($offset)
 {
     return $this->results->offsetGet($offset);
 }
 /**
  * Offset to retrieve
  * @link http://php.net/manual/en/arrayaccess.offsetget.php
  *
  * @param mixed $offset <p>
  * The offset to retrieve.
  * </p>
  *
  * @return mixed Can return all value types.
  * @since 5.0.0
  */
 public function offsetGet($offset)
 {
     return $this->fields->offsetGet($offset);
 }
Example #8
0
 public function offsetGet($key)
 {
     return parent::offsetGet(strtoupper($key));
 }