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


PHP Hash::numeric方法代码示例

本文整理汇总了PHP中Cake\Utility\Hash::numeric方法的典型用法代码示例。如果您正苦于以下问题:PHP Hash::numeric方法的具体用法?PHP Hash::numeric怎么用?PHP Hash::numeric使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Utility\Hash的用法示例。


在下文中一共展示了Hash::numeric方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _processIds

 /**
  * Retrieves a list of ids to process
  *
  * @return array
  */
 protected function _processIds()
 {
     $ids = $this->_controller()->request->data('id');
     $all = false;
     if (is_array($ids)) {
         $all = Hash::get((array) $ids, '_all', false);
         unset($ids['_all']);
     }
     if (!is_array($ids) || !Hash::numeric(array_keys($ids))) {
         throw new BadRequestException('Bad request data');
     }
     if ($all) {
         foreach ($ids as $key => $value) {
             $ids[$key] = 1;
         }
     }
     $ids = array_filter($ids);
     return array_keys($ids);
 }
开发者ID:GeBender,项目名称:Teste-DotGroup,代码行数:24,代码来源:BaseAction.php

示例2: testNumeric

 /**
  * testNumericArrayCheck method
  *
  * @return void
  */
 public function testNumeric()
 {
     $data = ['one'];
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = [1 => 'one'];
     $this->assertFalse(Hash::numeric($data));
     $data = ['one'];
     $this->assertFalse(Hash::numeric($data));
     $data = ['one' => 'two'];
     $this->assertFalse(Hash::numeric($data));
     $data = ['one' => 1];
     $this->assertTrue(Hash::numeric($data));
     $data = [0];
     $this->assertTrue(Hash::numeric($data));
     $data = ['one', 'two', 'three', 'four', 'five'];
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = [1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five'];
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = ['1' => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five'];
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = ['one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five'];
     $this->assertFalse(Hash::numeric(array_keys($data)));
     $data = [2.4, 1, 0, -1, -2];
     $this->assertTrue(Hash::numeric($data));
 }
开发者ID:jdaosavanh,项目名称:clickerwebapp,代码行数:30,代码来源:HashTest.php

示例3: _serialize

 /**
  * Serialize view vars.
  *
  * ### Special parameters
  * `_xmlOptions` You can set an array of custom options for Xml::fromArray() this way, e.g.
  *   'format' as 'attributes' instead of 'tags'.
  *
  * @param array|string $serialize The name(s) of the view variable(s) that need(s) to be serialized
  * @return string The serialized data
  */
 protected function _serialize($serialize)
 {
     $rootNode = isset($this->viewVars['_rootNode']) ? $this->viewVars['_rootNode'] : 'response';
     if ($serialize === true) {
         $serialize = array_diff(array_keys($this->viewVars), $this->_specialVars);
         if (empty($serialize)) {
             $serialize = null;
         } elseif (count($serialize) === 1) {
             $serialize = current($serialize);
         }
     }
     if (is_array($serialize)) {
         $data = [$rootNode => []];
         foreach ($serialize as $alias => $key) {
             if (is_numeric($alias)) {
                 $alias = $key;
             }
             if (array_key_exists($key, $this->viewVars)) {
                 $data[$rootNode][$alias] = $this->viewVars[$key];
             }
         }
     } else {
         $data = isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null;
         if (is_array($data) && Hash::numeric(array_keys($data))) {
             $data = [$rootNode => [$serialize => $data]];
         }
     }
     $options = [];
     if (isset($this->viewVars['_xmlOptions'])) {
         $options = $this->viewVars['_xmlOptions'];
     }
     if (Configure::read('debug')) {
         $options['pretty'] = true;
     }
     if (isset($options['return']) && strtolower($options['return']) === 'domdocument') {
         return Xml::fromArray($data, $options)->saveXML();
     }
     return Xml::fromArray($data, $options)->asXML();
 }
开发者ID:AlexandreSGV,项目名称:siteentec,代码行数:49,代码来源:XmlView.php

示例4: _serialize

 /**
  * Serialize view vars.
  *
  * @param array|string $serialize The name(s) of the view variable(s) that need(s) to be serialized
  * @return string The serialized data
  */
 protected function _serialize($serialize)
 {
     $rootNode = isset($this->viewVars['_rootNode']) ? $this->viewVars['_rootNode'] : 'response';
     if (is_array($serialize)) {
         $data = [$rootNode => []];
         foreach ($serialize as $alias => $key) {
             if (is_numeric($alias)) {
                 $alias = $key;
             }
             $data[$rootNode][$alias] = $this->viewVars[$key];
         }
     } else {
         $data = isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null;
         if (is_array($data) && Hash::numeric(array_keys($data))) {
             $data = [$rootNode => [$serialize => $data]];
         }
     }
     $options = [];
     if (Configure::read('debug')) {
         $options['pretty'] = true;
     }
     return Xml::fromArray($data, $options)->asXML();
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:29,代码来源:XmlView.php

示例5: testNumeric

 /**
  * testNumericArrayCheck method
  *
  * @return void
  */
 public function testNumeric()
 {
     $data = array('one');
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = array(1 => 'one');
     $this->assertFalse(Hash::numeric($data));
     $data = array('one');
     $this->assertFalse(Hash::numeric($data));
     $data = array('one' => 'two');
     $this->assertFalse(Hash::numeric($data));
     $data = array('one' => 1);
     $this->assertTrue(Hash::numeric($data));
     $data = array(0);
     $this->assertTrue(Hash::numeric($data));
     $data = array('one', 'two', 'three', 'four', 'five');
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five');
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = array('1' => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five');
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = array('one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five');
     $this->assertFalse(Hash::numeric(array_keys($data)));
     $data = array(2.4, 1, 0, -1, -2);
     $this->assertTrue(Hash::numeric($data));
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:30,代码来源:HashTest.php

示例6: _serialize

 /**
  * Serialize view vars.
  *
  * @param string|array $serialize The viewVars that need to be serialized.
  * @return string The serialized data
  * @throws RuntimeException When the prefix is not specified
  */
 protected function _serialize($serialize)
 {
     $rootNode = isset($this->viewVars['_rootNode']) ? $this->viewVars['_rootNode'] : 'channel';
     if (is_array($serialize)) {
         $data = [$rootNode => []];
         foreach ($serialize as $alias => $key) {
             if (is_numeric($alias)) {
                 $alias = $key;
             }
             $data[$rootNode][$alias] = $this->viewVars[$key];
         }
     } else {
         $data = isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null;
         if (is_array($data) && Hash::numeric(array_keys($data))) {
             $data = [$rootNode => [$serialize => $data]];
         }
     }
     $defaults = ['document' => [], 'channel' => [], 'items' => []];
     $data += $defaults;
     if (!empty($data['document']['namespace'])) {
         foreach ($data['document']['namespace'] as $prefix => $url) {
             $this->setNamespace($prefix, $url);
         }
     }
     $channel = $this->channel($data['channel']);
     if (!empty($channel['image']) && empty($channel['image']['title'])) {
         $channel['image']['title'] = $channel['title'];
     }
     foreach ($data['items'] as $item) {
         $channel['item'][] = $this->_prepareOutput($item);
     }
     $array = ['rss' => ['@version' => $this->version, 'channel' => $channel]];
     $namespaces = [];
     foreach ($this->_usedNamespaces as $usedNamespacePrefix) {
         if (!isset($this->_namespaces[$usedNamespacePrefix])) {
             throw new \RuntimeException(sprintf('The prefix %s is not specified.', $usedNamespacePrefix));
         }
         $namespaces['xmlns:' . $usedNamespacePrefix] = $this->_namespaces[$usedNamespacePrefix];
     }
     $array['rss'] += $namespaces;
     $options = [];
     if (Configure::read('debug')) {
         $options['pretty'] = true;
     }
     $output = Xml::fromArray($array, $options)->asXML();
     $output = $this->_replaceCdata($output);
     return $output;
 }
开发者ID:jxav,项目名称:cakephp-feed,代码行数:55,代码来源:RssView.php

示例7: _resolveFilters

 protected function _resolveFilters($type, $filters)
 {
     $filters = (array) $filters;
     $filterManager = $this->_getFilterManager($type);
     $keys = $filters;
     if (!Hash::numeric(array_keys($keys))) {
         $keys = array_keys($keys);
     }
     array_walk($filters, function (&$filter) use($filterManager) {
         if ('?' == $filter[0]) {
             $filter = substr($filter, 1);
         }
         if (!$filterManager->has($filter)) {
             throw new InvalidArgumentException(sprintf('Filter `%s` not configured.', $filter));
         }
         $filter = $filterManager->get($filter);
     });
     return array_combine($keys, $filters);
 }
开发者ID:gourmet,项目名称:assetic,代码行数:19,代码来源:AsseticTrait.php

示例8: _prepareFilter

 /**
  * @param string $property
  * @param string|array $value
  * @return array
  */
 protected function _prepareFilter($property, $value)
 {
     $filter = [];
     $comparisons = ['eq', 'seq', 'neq', 'gt', 'ge', 'gte', 'lt', 'le', 'lte', 'ct', 'sw', 'nct', 'ew', 'in', 'nin'];
     if (is_array($value) && !Hash::numeric(array_keys($value))) {
         foreach ($value as $comparison => $_value) {
             if (in_array($comparison, ['in', 'nin'])) {
                 // IN or NOT IN
                 $filter = ['property' => $property, 'value' => $this->_checkPropertyArrayValue($property, is_array($_value) ? $_value : [$_value]), 'comparison' => $comparison];
             } elseif (in_array($comparison, $comparisons)) {
                 // OTHER CLAUSE
                 if ($this->getManager()->checkProperty($property, $_value, true)) {
                     $filter = ['property' => $property, 'value' => $_value, 'comparison' => $comparison];
                 }
             } else {
                 if ($this->_client->isDebugMode()) {
                     throw new Exception("La clause \"{$comparison}\" n'existe pas");
                 }
             }
         }
     } elseif (is_array($value)) {
         // IN
         $filter = ['property' => $property, 'value' => $this->_checkPropertyArrayValue($property, $value)];
     } else {
         // EQUAL
         if ($this->getManager()->checkProperty($property, $value, true)) {
             $filter = ['property' => $property, 'value' => $value];
         }
     }
     return $filter;
 }
开发者ID:fidesio,项目名称:isidore-bundle,代码行数:36,代码来源:StoreRepository.php


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