示例#1
0
文件: CCArr.php 项目: clancats/core
 /**
  * get the average of the items 
  *
  * @param array[array]	$arr
  * @param string			$key
  */
 public static function average($arr, $key = null)
 {
     if (!is_array($arr)) {
         throw new \InvalidArgumentException('CCArr::average - first argunent has to be an array.');
     }
     if (is_string($key) && CCArr::is_multi($arr)) {
         $arr = CCArr::pick($key, $arr);
     }
     return static::sum($arr) / count($arr);
 }
示例#2
0
文件: CCArr.php 项目: clancats/core
 /**
  * test values by key
  *
  * @expectedException        InvalidArgumentException
  */
 public function testArrayPickException()
 {
     CCArr::pick('test');
 }