Beispiel #1
0
 /**
  * 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);
 }
Beispiel #2
0
 /**
  * test values by key
  *
  * @expectedException        InvalidArgumentException
  */
 public function testArrayPickException()
 {
     CCArr::pick('test');
 }