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


PHP Arrays::isAssoc方法代码示例

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


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

示例1: make

 public function make($data)
 {
     $data = is_object($data) && $data instanceof Container ? $data->assoc() : $data;
     if (!Arrays::isAssoc($data)) {
         throw new Exception("This method needs a valid object to process.");
     }
     $e = $data['entity'] = $this->entity;
     $class = $this;
     $obj = new Container();
     $store = function () use($obj, $e) {
         $class = new Attributes($e);
         return $class->save($obj);
     };
     $remove = function () use($obj, $e) {
         $class = new Attributes($e);
         return $class->delete($obj);
     };
     $date = function ($f) use($obj) {
         return date('Y-m-d H:i:s', $obj->{$f});
     };
     $display = function ($f, $echo = true) use($obj) {
         if (false === $echo) {
             return Html\Helper::display($obj->{$f});
         } else {
             echo Html\Helper::display($obj->{$f});
         }
     };
     $obj->event('store', $store)->event('trash', $remove)->event('date', $date)->event('display', $display);
     foreach ($data as $k => $v) {
         if (!isset($obj->{$k})) {
             $obj->{$k} = $v;
         }
     }
     return $obj;
 }
开发者ID:schpill,项目名称:thin,代码行数:35,代码来源:Attributes.php

示例2: createObject

 public static function createObject($className, $classParams = null)
 {
     if (is_array($classParams) && !Arrays::isAssoc($classParams)) {
         // Invoke Object with multiple arguments
         return new $className(...$classParams);
     }
     // Invoke Object with single argument
     return new $className($classParams);
 }
开发者ID:kodcube,项目名称:helpers,代码行数:9,代码来源:Classes.php

示例3: __construct

 public function __construct(array $array, $callback = null)
 {
     $path = CACHE_PATH . DS . Utils::UUID();
     File::mkdir($path);
     File::put($file, "<?php\nreturn " . var_export($array, 1) . ';');
     $this->assoc = Arrays::isAssoc($array);
     $this->file = $file;
     $this->callback = $callback;
     $this->count = count($array);
 }
开发者ID:schpill,项目名称:standalone,代码行数:10,代码来源:iterator.php

示例4: closures

 private function closures($obj)
 {
     $settings = isAke(self::$configs, $this->entity);
     $class = $this;
     $class->results = null;
     $class->wheres = null;
     $class->joins = null;
     $class->transactions = null;
     $extend = function ($name, $callable) use($obj) {
         if (is_callable($callable)) {
             $share = function () use($obj, $callable) {
                 $args = func_get_args();
                 $args[] = $obj;
                 return call_user_func_array($callable, $args);
             };
             $obj->event($name, $share);
         }
     };
     $export = function () use($class, $obj) {
         if (isset($obj->id)) {
             $class->where("id = " . $obj->id)->export();
         }
     };
     $save = function () use($class, $obj) {
         return $class->save($obj->assoc());
     };
     $delete = function () use($class, $obj) {
         return $class->delete($obj->getId());
     };
     $date = function ($f) use($obj) {
         return date('Y-m-d H:i:s', $obj->{$f});
     };
     $hydrate = function ($data = array()) use($obj) {
         $data = empty($data) ? $_POST : $data;
         if (Arrays::isAssoc($data)) {
             foreach ($data as $k => $v) {
                 if ("true" == $v) {
                     $v = true;
                 } elseif ("false" == $v) {
                     $v = false;
                 } elseif ("null" == $v) {
                     $v = null;
                 }
                 $obj->{$k} = $v;
             }
         }
         return $obj;
     };
     $display = function ($field, $echo = true) use($obj) {
         $val = Html\Helper::display($obj->{$field});
         if (true === $echo) {
             echo $val;
         } else {
             return $val;
         }
     };
     $tab = function () use($obj) {
         return $obj->assoc();
     };
     $asset = function ($field) use($obj) {
         return '/storage/img/' . $obj->{$field};
     };
     $string = function () use($obj) {
         return $obj->id;
     };
     $obj->event('save', $save)->event('delete', $delete)->event('extend', $extend)->event('date', $date)->event('hydrate', $hydrate)->event('tab', $tab)->event('string', $string)->event('export', $export)->event('display', $display);
     $functions = isAke($settings, 'functions');
     if (count($functions)) {
         foreach ($functions as $closureName => $callable) {
             $closureName = lcfirst(Inflector::camelize($closureName));
             $share = function () use($obj, $callable) {
                 $args = func_get_args();
                 $args[] = $obj;
                 return call_user_func_array($callable, $args);
             };
             $obj->event($closureName, $share);
         }
     }
     return $obj;
 }
开发者ID:schpill,项目名称:thin,代码行数:80,代码来源:Txtdata.php

示例5: closures

 private function closures($obj)
 {
     $settings = isAke(self::$configs, $this->entity);
     $class = $this;
     $class->results = null;
     $class->wheres = null;
     $class->joins = null;
     $class->transactions = null;
     $export = function () use($class, $obj) {
         if (isset($obj->id)) {
             $class->where("id = " . $obj->id)->export();
         }
     };
     $save = function () use($class, $obj) {
         return $class->save($obj->assoc());
     };
     $delete = function () use($class, $obj) {
         return $class->delete($obj->getId());
     };
     $date = function ($f) use($obj) {
         return date('Y-m-d H:i:s', $obj->{$f});
     };
     $hydrate = function ($data) use($obj) {
         if (Arrays::isAssoc($data)) {
             foreach ($data as $k => $v) {
                 $obj->{$k} = $v;
             }
         }
         return $obj;
     };
     $display = function ($field, $echo = true) use($obj) {
         $val = Html\Helper::display($obj->{$field});
         if (true === $echo) {
             echo $val;
         } else {
             return $val;
         }
     };
     $tab = function () use($obj) {
         return $obj->assoc();
     };
     $asset = function ($field) use($obj) {
         return '/storage/img/' . $obj->{$field};
     };
     $extend = function ($n, \Closure $f) use($obj) {
         if (version_compare(PHP_VERSION, '5.4.0', "<")) {
             $share = function () use($obj, $f) {
                 return $f($obj);
             };
         } else {
             $share = $f->bindTo($obj);
         }
         $obj->event($n, $share);
     };
     $obj->event('save', $save)->event('delete', $delete)->event('extend', $extend)->event('date', $date)->event('hydrate', $hydrate)->event('tab', $tab)->event('export', $export)->event('display', $display);
     $functions = isAke($settings, 'functions');
     if (count($functions)) {
         foreach ($functions as $closureName => $callable) {
             $closureName = lcfirst(Inflector::camelize($closureName));
             if (version_compare(PHP_VERSION, '5.4.0', "<")) {
                 $share = function () use($obj, $callable) {
                     return $callable($obj);
                 };
             } else {
                 $share = $callable->bindTo($obj);
             }
             $obj->event($closureName, $share);
         }
     }
     return $obj;
 }
开发者ID:noikiy,项目名称:inovi,代码行数:71,代码来源:Bucketdb.php

示例6: row

 public function row(array $values)
 {
     $class = $this;
     $class->results = null;
     $class->wheres = null;
     $obj = new Container();
     $save = function () use($class, $obj) {
         return $class->push($obj->assoc());
     };
     $delete = function () use($class, $obj) {
         return $class->pop($obj->getId());
     };
     $date = function ($f) use($obj) {
         return date('Y-m-d H:i:s', $obj->{$f});
     };
     $hydrate = function ($data) use($obj) {
         if (Arrays::isAssoc($data)) {
             foreach ($data as $k => $v) {
                 $obj->{$k} = $v;
             }
         }
         return $obj;
     };
     $display = function ($field) use($obj) {
         return Html\Helper::display($obj->{$field});
     };
     $tab = function () use($obj) {
         return $obj->assoc();
     };
     $asset = function ($field) use($obj) {
         return '/storage/img/' . $obj->{$field};
     };
     $obj->event('save', $save)->event('delete', $delete)->event('date', $date)->event('hydrate', $hydrate)->event('tab', $tab)->event('asset', $asset)->event('display', $display);
     return $obj->populate($values);
 }
开发者ID:schpill,项目名称:thin,代码行数:35,代码来源:Jsondb.php

示例7: getFullPrice

 public static function getFullPrice()
 {
     $ret = 0;
     $items = null === static::$session->getItems() ? array() : static::$session->getItems();
     if (count($items)) {
         foreach ($items as $item) {
             if (Arrays::isAssoc($item)) {
                 $quantity = isAke($item, 'quantity');
                 $price = isAke($itemd, 'price');
                 if (!empty($quantity) && !empty($price)) {
                     $ret += $item['price'] * $item['quantity'];
                 }
             }
         }
     }
     return $ret;
 }
开发者ID:schpill,项目名称:thin,代码行数:17,代码来源:Basket.php

示例8: setup

 /**
  * Sets up the TinyQueries environment
  *
  */
 public function setup()
 {
     $setupFile = dirname(__FILE__) . '/../config/setup.php';
     // Don't throw error, but just return informative message
     if (!file_exists($setupFile)) {
         return array('message' => 'Nothing to do - No setup script found');
     }
     include $setupFile;
     if (!function_exists('TinyQueries\\setup')) {
         throw new \Exception('There is no function \'TinyQueries\\setup\' defined in setup.php');
     }
     $result = setup();
     if (Arrays::isAssoc($result)) {
         return $result;
     }
     return array('message' => 'TinyQueries setup complete');
 }
开发者ID:wdiesveld,项目名称:tiny-queries-php-api,代码行数:21,代码来源:TinyQueries.php

示例9: closures

 private function closures($obj)
 {
     $db = $this->model;
     $db->results = null;
     $db->wheres = null;
     $save = function () use($obj, $db) {
         return $db->save($obj);
     };
     $database = function () use($db) {
         return $db;
     };
     $delete = function () use($obj, $db) {
         return $db->deleteRow($obj->id);
     };
     $id = function () use($obj) {
         return $obj->id;
     };
     $exists = function () use($obj) {
         return isset($obj->id);
     };
     $touch = function () use($obj) {
         if (!isset($obj->created_at)) {
             $obj->created_at = time();
         }
         $obj->updated_at = time();
         return $obj;
     };
     $duplicate = function () use($obj, $db) {
         $obj->copyrow = Utils::token();
         $data = $obj->assoc();
         unset($data['id']);
         unset($data['created_at']);
         unset($data['updated_at']);
         $obj = $db->row($data);
         return $obj->save();
     };
     $hydrate = function ($data = []) use($obj) {
         $data = empty($data) ? $_POST : $data;
         if (Arrays::isAssoc($data)) {
             foreach ($data as $k => $v) {
                 if ('true' == $v) {
                     $v = true;
                 } elseif ('false' == $v) {
                     $v = false;
                 } elseif ('null' == $v) {
                     $v = null;
                 }
                 $obj->{$k} = $v;
             }
         }
         return $obj;
     };
     $date = function ($f) use($obj) {
         return date('Y-m-d H:i:s', $obj->{$f});
     };
     $obj->event('save', $save)->event('delete', $delete)->event('date', $date)->event('exists', $exists)->event('id', $id)->event('db', $database)->event('touch', $touch)->event('hydrate', $hydrate)->event('duplicate', $duplicate);
     $settings = isAke(Db::$config, "{$this->model}->db.{$this->model}->table");
     $functions = isAke($settings, 'functions');
     if (count($functions)) {
         foreach ($functions as $closureName => $callable) {
             $closureName = lcfirst(Inflector::camelize($closureName));
             $share = function () use($obj, $callable, $db) {
                 $args[] = $obj;
                 $args[] = $db;
                 return call_user_func_array($callable, $args);
             };
             $obj->event($closureName, $share);
         }
     }
     return $this->related($obj);
 }
开发者ID:schpill,项目名称:standalone,代码行数:71,代码来源:Record.php


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