本文整理汇总了PHP中ArrayIterator::offsetGet方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayIterator::offsetGet方法的具体用法?PHP ArrayIterator::offsetGet怎么用?PHP ArrayIterator::offsetGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayIterator
的用法示例。
在下文中一共展示了ArrayIterator::offsetGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParam
public function getParam($name, $default = null)
{
$value = $default;
if ($this->params->offsetExists($name)) {
$value = $this->params->offsetGet($name);
}
return $value;
}
示例2: getLocation
/**
* @param $locId
* @return LocationHelper
* @throws \Exception
*/
public function getLocation($locId)
{
if ($this->locations->offsetExists($locId)) {
return $this->locations->offsetGet($locId);
} else {
return $this->locHelper->factory($locId);
}
}
示例3: offsetGet
public function offsetGet($offset)
{
$name = $this->_normalizeHeaderName($offset);
if (!parent::offsetExists($name)) {
throw new Bringit_Exception("Header '{$name}' not in ");
}
return parent::offsetGet($name);
}
示例4: offsetGet
public function offsetGet($k)
{
$k = $this->normalize($k);
if (is_null($k)) {
return '';
}
return parent::offsetGet($k);
}
示例5: offsetGet
public function offsetGet($index)
{
static $i = 0;
echo __METHOD__ . "({$index})\n";
if (++$i > 3) {
exit(1);
}
return parent::offsetGet($index);
}
示例6: reflect
/**
* Reflect the handle class
*
* @param string $class
* @return Collection\Method
* @throws Exception\InvalidArgument
*/
public function reflect($class)
{
if (class_exists($class) === false) {
throw new Exception\InvalidArgument(sprintf($this->exceptions[1], $class), 1);
}
// Check if we've already reflected this class
if (static::$reflections->offsetExists($class)) {
return static::$reflections->offsetGet($class);
}
// Create reflection
$reflectionClass = new \ReflectionClass($class);
$reflectionMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC);
// Method container
$methods = new Collection\Method();
// Loop through the class methods (Only public);
foreach ($reflectionMethods as $reflectionMethod) {
// Create method information entity
$method = new Entity\Method();
$method->setName($reflectionMethod->getName());
// Get method parameters
$reflectionParams = $reflectionMethod->getParameters();
// Evaluate the method params
foreach ($reflectionParams as $reflectionParam) {
// Create parameter information entity
$parameter = new Entity\Parameter();
$parameter->setIndex($reflectionParam->getPosition());
$parameter->setName($reflectionParam->getName());
$parameter->setRequired($reflectionParam->isDefaultValueAvailable() === false);
// Only set default value when param is optional
if ($parameter->getRequired() === false) {
$parameter->setDefault($reflectionParam->getDefaultValue());
}
// Add the parameter to the container
$method->addParameter($parameter);
}
// Add the method to the method container
$methods->offsetSet(strtolower($method->getName()), $method);
}
// Cache reflection in the runtime
self::$reflections->offsetSet($class, $methods);
// Return the methods
return $methods;
}
示例7: config
public function config(ArrayIterator $cotations)
{
$minValue = $cotations->offsetGet(0)->getClose();
$maxValue = $cotations->offsetGet(0)->getClose();
while ($cotations->valid()) {
$cotation = $this->returnCotation($cotations->current());
$date = explode("-", $cotation->getDate());
$date = date("d/m/Y", mktime(0, 0, 0, $date[1], $date[2], $date[0]));
if ($maxValue < $cotation->getClose()) {
$maxValue = $cotation->getClose();
}
if ($minValue > $cotation->getClose()) {
$minValue = $cotation->getClose();
}
$this->simpleSeries->setValue($cotation->getClose(), $date);
$cotations->next();
}
$this->configureMinMaxYValues($minValue, $maxValue);
}
示例8: getHandler
/**
* Get the handler based on the namespace
*
* @param string $namespace
* @return object
* @throws Exception\ArgumentException
*/
protected function getHandler($namespace)
{
// Chack if namespace has been registered
if ($this->handlers->offsetExists($namespace) === false) {
throw new Exception\InvalidArgument(sprintf($this->exceptions[1], $namespace), 1);
}
// Create instance when needed
if ($this->handlerInstances->offsetExists($namespace) === false) {
$handler = $this->handlers->offsetGet($namespace);
$this->handlerInstances->offsetSet($namespace, new $handler());
}
// Return instance
return $this->handlerInstances->offsetGet($namespace);
}
示例9: offsetGet
/**
* \WP_Widget::update_callback(): $old_instance = isset($all_instances[$number]) ? $all_instances[$number] : array();
* \WP_Widget::display_callback(): $instance = $instance[$this->number];
* \WP_Widget::form_callback(): $instance = $all_instances[ $widget_args['number'] ];
*
* @param int|string $key Array key.
* @return array|int|null
*/
public function offsetGet($key)
{
if ('_multiwidget' === $key) {
return 1;
}
if (!$this->offsetExists($key)) {
return null;
}
$value = parent::offsetGet($key);
if (is_int($value)) {
// Fetch the widget post_content_filtered and store it in the array.
$post = get_post($value);
$value = Widget_Posts::get_post_content_filtered($post);
$this->offsetSet($key, $value);
}
return $value;
}
示例10: config
public function config(ArrayIterator $cotations)
{
$i = 1;
$date = $cotations->offsetGet(0)->getDate();
$dateInParts = explode('-', $date);
$month = $dateInParts[1];
while ($cotations->valid()) {
$cot = $this->returnCotation($cotations->current());
$currentMonth = $this->getCurrentMonth($cot->getDate());
if ($this->monthIsDiferent($currentMonth, $month)) {
$month = $currentMonth;
$this->multiSeries->addCategory($this->translateMonth($month));
$this->multiSeries->addCategoryAttribute($this->translateMonth($month), "x", $i);
}
$this->multiSeries->setValue("all_values", $cot->getOpen(), $cot->getMax(), $cot->getMin(), $cot->getClose(), $i);
$this->addTextToTooltipInASet('all_values', $i, $cot);
$i++;
$cotations->next();
}
}
示例11: check
/**
* Check input against the Rules configured for this Validator.
*
* @param array|object|Persistent $input The input data to check.
* @param bool $all If true, all rules will be checked even if the field
* does not exist in the input data.
*
* @return bool True if all Rules pass, false otherwise.
*/
public function check($input, $all = false)
{
$data = new \ArrayIterator($input);
foreach ($this->ruleSet as $field => $rules) {
if ($all || $data->offsetExists($field)) {
$fieldValue = $data->offsetExists($field) ? $data->offsetGet($field) : null;
foreach (explode('|', $rules) as $ruleDef) {
$ruleExploded = explode(':', $ruleDef, 2);
$rule = $ruleExploded[0];
$ruleArgs = isset($ruleExploded[1]) ? explode(',', $ruleExploded[1]) : [];
try {
Rules::$rule($field, $fieldValue, $ruleArgs);
} catch (ValidationFailedException $failure) {
$this->addFailure($field, $failure->getMessage(), $failure->getCode());
$this->failed = true;
}
}
}
}
$this->checked = true;
return $this->failed === false;
}
示例12: array
*/
$array = array('value1', 'value3', 'value2', 'value4', 'value5');
try {
$object = new ArrayIterator($array);
// 判断第二个节点是否存在
if ($object->offsetExists(2)) {
// 给第二个节点赋新值
$object->offsetSet(2, 'value2_1');
}
// 在数组最后插入新值
$object->append('value_6');
// 自然排序排序 natsort(): 数组进行自然排序; natcasesort():对数组进行自然排序,并不区分大小写
// uasort(): uksort(): 通过在参数中传递已定义的排序方式进行排序;
$object->natsort();
// 检查key为3所对应的值
$object->offsetGet(3);
// 销毁key为3的值
$object->offsetUnset(3);
// 指针跳转到第5个节点
$object->seek(4);
// foreach 循环
/**
* 如下的写法经调试出现了一个bug。
* 当在循环中进行offsetUnset时,此时,当前指针会回跳会第一个节点,即$object->key()的值为0,但是此时循环的key值和value值并没有变,依然是3=>value4。
* 而再次foreach循环之前,$object->key()值为0.循环后,$object->key()为1,所有,此时循环重复值。
*/
foreach ($object as $key => $value) {
echo '<li>' . $key . '=>' . $value . '</li>' . "\n";
}
// while 循环
$object->rewind();
示例13: offsetGet
/**
* Get value for an offset
*
* @param string $index
* @return string
*/
public function offsetGet($index)
{
if (!parent::offsetExists($index)) {
return null;
}
$value = parent::offsetGet($index);
return $this->cast($index, $value);
}
示例14: offsetGet
/**
* (PHP 5 >= 5.0.0)<br/>
* Get value for an offset
* @link http://php.net/manual/en/arrayiterator.offsetget.php
* @param string $index <p>
* The offset to get the value from.
* </p>
* @return mixed The value at offset <i>index</i>.
*/
public function offsetGet($index)
{
$element = parent::offsetGet($index);
return $element[PriorityArrayElementsContainerFactory::VALUE_KEY_NAME];
}
示例15: checkMimeTypes
/**
* Verifica o mime type do arquivo
* @return boolean
*/
public function checkMimeTypes()
{
$fileExtension = $this->getFileExtension();
$fileMimeType = $this->getMimeTypeFile();
$oIMines = $this->getMimeTypes()->getIterator();
$oIExtension = $this->getExtension()->getIterator();
$valid = new \ArrayIterator();
while ($oIExtension->valid()) {
$current = $oIExtension->current();
if ($oIMines->offsetExists($current)) {
$valid->offsetSet($current, $oIMines->offsetGet($current));
}
$oIExtension->next();
}
if ($valid->offsetExists($fileExtension)) {
$item = $valid->offsetGet($fileExtension);
if (is_array($item)) {
if (in_array($fileMimeType, $item)) {
return true;
} else {
$this->setMessageError("error_mime_type");
return false;
}
} else {
if ($fileMimeType == $item) {
return true;
} else {
$this->setMessageError("error_mime_type");
return false;
}
}
} else {
$this->setMessageError("error_mime_type");
return false;
}
}