当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayIterator::offsetGet方法代码示例

本文整理汇总了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;
 }
开发者ID:artprima,项目名称:ixa-wp-config,代码行数:8,代码来源:EnvironmentConfig.php

示例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);
     }
 }
开发者ID:mbabenko21,项目名称:likedimion-game,代码行数:13,代码来源:Supervision.php

示例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);
 }
开发者ID:pda,项目名称:bringit,代码行数:8,代码来源:RequestHeader.php

示例4: offsetGet

 public function offsetGet($k)
 {
     $k = $this->normalize($k);
     if (is_null($k)) {
         return '';
     }
     return parent::offsetGet($k);
 }
开发者ID:josejoaosantos,项目名称:wp-loco,代码行数:8,代码来源:gettext-compiled.php

示例5: offsetGet

 public function offsetGet($index)
 {
     static $i = 0;
     echo __METHOD__ . "({$index})\n";
     if (++$i > 3) {
         exit(1);
     }
     return parent::offsetGet($index);
 }
开发者ID:gleamingthecube,项目名称:php,代码行数:9,代码来源:ext_spl_tests_bug32134.php

示例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;
 }
开发者ID:jdolieslager,项目名称:jsonrpc,代码行数:50,代码来源:HandlerReflectionMaker.php

示例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);
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:19,代码来源:SimpleSeriesConfig.php

示例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);
 }
开发者ID:jdolieslager,项目名称:jsonrpc,代码行数:21,代码来源:Server.php

示例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;
 }
开发者ID:BE-Webdesign,项目名称:wp-customize-widgets-plus,代码行数:25,代码来源:class-widget-settings.php

示例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();
     }
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:20,代码来源:MultiSeriesCandleConfig.php

示例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;
 }
开发者ID:vgrish,项目名称:tacit,代码行数:31,代码来源:Validator.php

示例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();
开发者ID:ray0916,项目名称:learn,代码行数:31,代码来源:iterator.php

示例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);
 }
开发者ID:sachsy,项目名称:formbuilder,代码行数:14,代码来源:Attr.php

示例14: offsetGet

 /**
  * (PHP 5 &gt;= 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];
 }
开发者ID:dicomresearch,项目名称:priority-array,代码行数:14,代码来源:PriorityArrayIterator.php

示例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;
     }
 }
开发者ID:avandrevitor,项目名称:S9,代码行数:40,代码来源:FileUpload.php


注:本文中的ArrayIterator::offsetGet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。