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


PHP Thin\Arrays类代码示例

本文整理汇总了PHP中Thin\Arrays的典型用法代码示例。如果您正苦于以下问题:PHP Arrays类的具体用法?PHP Arrays怎么用?PHP Arrays使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: resolveCommands

 /**
  * Resolve an array of commands through the application.
  *
  * @param  array|dynamic  $commands
  * @return void
  */
 public function resolveCommands($commands)
 {
     $commands = Arrays::isArray($commands) ? $commands : func_get_args();
     foreach ($commands as $command) {
         $this->resolve($command);
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:13,代码来源:Application.php

示例2: __call

 public function __call($event, $args)
 {
     if (substr($event, 0, 3) == 'get') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($event, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return self::get($key);
     } elseif (substr($event, 0, 3) == 'set') {
         $value = Arrays::first($args);
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($event, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return self::set($key, $value);
     }
     if (true === self::__has($event)) {
         return self::__fire($event, $args);
     } else {
         $value = Arrays::first($args);
         if ($value instanceof Closure) {
             $eventable = self::__event($event, $value);
         } else {
             $set = function () use($value) {
                 return $value;
             };
             $eventable = self::__event($event, $set);
         }
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:26,代码来源:Di.php

示例3: __call

 public function __call($event, $args)
 {
     if (substr($event, 0, 3) == 'get' && strlen($event) > 3) {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($event, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return $this->get($key);
     } elseif (substr($event, 0, 3) == 'set' && strlen($event) > 3) {
         $value = Arrays::first($args);
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($event, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return $this->set($key, $value);
     }
     if (true === $this->__has($event)) {
         array_push($args, $this);
         return $this->__fire($event, $args);
     } else {
         if (method_exists($this, $event)) {
             throw new Exception("The method {$event} is a native class' method. Please choose an other name.");
         }
         $value = Arrays::first($args);
         if ($value instanceof Closure) {
             $eventable = $this->__event($event, $value);
         } else {
             $set = function () use($value) {
                 return $value;
             };
             $eventable = $this->__event($event, $set);
         }
         return $this;
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:31,代码来源:Context.php

示例4: __construct

 /**
  * Constructor
  *
  * @param array $config
  */
 public function __construct(array $config = [])
 {
     // Populate Keyring
     Keyring::setAppKey($config['AK']);
     // Application Key
     Keyring::setAppSecret($config['AS']);
     // Application Secret
     Keyring::setConsumerKey($config['CK']);
     // Consumer Key
     // Backward compatibility
     if (Arrays::exists('RG', $config)) {
         Keyring::setAppUrlRegion($config['RG']);
         // Region
     } else {
         Keyring::setAppUrlRegion("FR");
     }
     if (Arrays::exists('protocol', $config)) {
         Keyring::setAppHost($config['protocol']);
         // protocol
     } else {
         Keyring::setAppHost(static::$zeliftApiProtocol);
     }
     if (Arrays::exists('host', $config)) {
         Keyring::setAppProtocol($config['host']);
         // host
     } else {
         Keyring::setAppProtocol(static::$zeliftApiHost);
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:34,代码来源:Api.php

示例5: run

 public function run()
 {
     if (fnmatch('*cli*', php_sapi_name())) {
         $dir = Config::get('dir.schedules', APPLICATION_PATH . DS . 'schedules');
         if (is_dir($dir)) {
             Timer::start();
             Cli::show("Start of execution", 'COMMENT');
             $files = glob($dir . DS . '*.php');
             foreach ($files as $file) {
                 require_once $file;
                 $object = str_replace('.php', '', Arrays::last(explode(DS, $file)));
                 $class = 'Thin\\' . ucfirst(Inflector::camelize($object . '_schedule'));
                 $instance = lib('app')->make($class);
                 $methods = get_class_methods($instance);
                 Cli::show("Start schedule '{$object}'", 'COMMENT');
                 foreach ($methods as $method) {
                     $when = $this->getWhen($instance, $method);
                     $isDue = $this->isDue($object, $method, $when);
                     if (true === $isDue) {
                         Cli::show("Execution of {$object}->{$method}", 'INFO');
                         $instance->{$method}();
                     } else {
                         Cli::show("No need to execute {$object}->{$method}", 'QUESTION');
                     }
                 }
             }
             Cli::show("Time of execution [" . Timer::get() . " s.]", 'SUCCESS');
             Cli::show("end of execution", 'COMMENT');
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:31,代码来源:schedule.php

示例6: __get

 /**
  * Getter
  * @param mixed $key
  * @return mixed
  */
 public function __get($key)
 {
     if (Arrays::exists($key, $this->data)) {
         return $this->data[$key];
     } else {
         return false;
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:13,代码来源:HTTPException.php

示例7: get

 /**
  * Get an Instantiated ReflectionClass.
  *
  * @param string $class Optional name of a class
  * @return mixed null or a ReflectionClass instance
  * @throws Exception if class was not found
  */
 public function get($class = null)
 {
     $class = $this->getClass($class);
     if (Arrays::exists($class, $this->reflections)) {
         return $this->reflections[$class];
     }
     throw new Exception("Class not found: {$class}");
 }
开发者ID:schpill,项目名称:thin,代码行数:15,代码来源:Reflection.php

示例8: beginTransaction

 public function beginTransaction()
 {
     $last = Arrays::last(explode(DS, $this->dir));
     $target = str_replace(DS . $last, DS . 'copy.' . $last, $this->dir);
     File::cpdir($this->dir, $target);
     $this->dir = $target;
     return $this;
 }
开发者ID:schpill,项目名称:standalone,代码行数:8,代码来源:Store.php

示例9: __construct

 /**
  * Creates a new navigation container
  *
  * @param array $pages  [optional] pages to add
  * @throws Exception    if $pages is invalid
  */
 public function __construct($pages = null)
 {
     if (Arrays::is($pages)) {
         $this->addPages($pages);
     } elseif (null !== $pages) {
         throw new Exception('Invalid argument: $pages must be an array or null');
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:14,代码来源:Navigation.php

示例10: where

 /**
  * where()
  * Sets where object
  * @access public
  * @param string $where
  * @param string $value
  * @return \Thin\Webquery
  */
 public function where($where = null, $value = null)
 {
     if (Arrays::is($this->where)) {
         $this->whereKey = count($this->where) + 1;
     }
     $this->where[$this->whereKey]['attr'] = $where;
     $this->where[$this->whereKey]['value'] = $value;
     return $this;
 }
开发者ID:schpill,项目名称:thin,代码行数:17,代码来源:Webquery.php

示例11: __construct

 /**
  * Construct new RangeQuery component
  *
  * @return \ElasticSearch\DSL\RangeQuery
  * @param array $options
  */
 public function __construct(array $options = [])
 {
     $this->fieldname = key($options);
     $values = Arrays::first($options);
     if (Arrays::is($values)) {
         foreach ($values as $key => $val) {
             $this->{$key} = $val;
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:16,代码来源:RangeQuery.php

示例12: remove

 public function remove($id)
 {
     if (!Arrays::exists($id, $this->services)) {
         throw new InvalidArgumentException(sprintf('Service "%s" is not defined.', $id));
     }
     list($prefix, $sid) = $this->getPrefixAndSid($id);
     if ($prefix) {
         unset($this->prefixed[$prefix][$sid]);
     }
     unset($this->services[$id]);
 }
开发者ID:schpill,项目名称:thin,代码行数:11,代码来源:Service.php

示例13: __construct

 public function __construct(array $array)
 {
     $this->key = sha1(serialize($array));
     if (Arrays::isAssoc($array)) {
         $tab = new SplFixedArray(1);
         $tab[0] = $array;
         $this->key .= 'AAA';
     } else {
         $tab = SplFixedArray::fromArray($array);
     }
     lib('resource')->set($this->key, $tab);
 }
开发者ID:schpill,项目名称:standalone,代码行数:12,代码来源:tab.php

示例14: read

 public function read($name, $default = null)
 {
     $file = $this->getFile($name);
     $content = $this->import($file);
     if ($content) {
         if (Arrays::isAssoc($content)) {
             return $content;
         }
         return current($content);
     }
     return $default;
 }
开发者ID:schpill,项目名称:standalone,代码行数:12,代码来源:Motor.php

示例15: config

 /**
  * Get or set a config
  *
  * @param string $key
  * @param mixed $value
  * @throws \Exception
  * @return array|void
  */
 public function config($key, $value = null)
 {
     if (Arrays::is($key)) {
         $this->config = $key + $this->config;
     } else {
         if ($value !== null) {
             $this->config[$key] = $value;
         }
         if (!isset($this->config[$key])) {
             throw new Exception("Configuration key `type` is not set");
         }
         return $this->config[$key];
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:22,代码来源:Mapping.php


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