code: public function average($path, $defaultValue = 0)
      {
          if ($this->items === null || (is_array($this->items) && count($this->items) == 0)) {
              return $defaultValue;
          }
          $sum = $this->sum($path, $defaultValue);
          if ($sum == 0) {
              return 0;
          }
          return $sum / count($this->items);
      }
docs: Average.
  
  @param string $path
  @param integer $defaultValue Default 0.
  @return float|integer