本文整理汇总了PHP中Illuminate\Support\Collection::offsetGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::offsetGet方法的具体用法?PHP Collection::offsetGet怎么用?PHP Collection::offsetGet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::offsetGet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: offsetGet
/**
* @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);
}
示例2: getHandlerForType
/**
* @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.");
}
示例3: defaults
/**
* 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();
}
示例4: offsetUnset
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);
}
}
示例5: testArrayAccessOffsetGetOnNonExist
/**
* @expectedException PHPUnit_Framework_Error_Notice
*/
public function testArrayAccessOffsetGetOnNonExist()
{
$c = new Collection(['foo', 'bar']);
$c->offsetGet(1000);
}
示例6: offsetGet
/**
* @param mixed $offset
* @return Record|null
*/
public function offsetGet($offset)
{
return $this->results->offsetGet($offset);
}
示例7: offsetGet
/**
* 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);
}
示例8: offsetGet
public function offsetGet($key)
{
return parent::offsetGet(strtoupper($key));
}