1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8class Math_Formula_Function_Mul extends Math_Formula_Function
9{
10	function evaluate($element)
11	{
12		$list = [];
13
14		foreach ($element as $child) {
15			$child = $this->evaluateChild($child);
16
17			if (is_array($child)) {
18				$list = array_merge($list, $child);
19			} else {
20				$list[] = $child;
21			}
22		}
23
24		if (empty($list)) {
25			return 1;
26		} else {
27			return array_product($list);
28		}
29	}
30}
31