public static function fromArrays() { $args = func_get_args(); $a = array(); foreach ($args as $arg) { if (is_array($arg)) { foreach ($arg as $v) { $k_actual = self::hacklib_makeKey($v); $a[$k_actual] = $v; } } else { throw new \InvalidArgumentException('Parameters must be arrays'); } } $o = new self(); $o->hacklib_setContainer($a); return $o; }
public static function fromItems($it) { if (is_array($it) || $it instanceof \Traversable) { $a = array(); foreach ($it as $v) { if ($v instanceof Pair) { $k_actual = self::hacklib_makeKey($v[0]); $a[$k_actual] = $v[1]; } else { throw new \InvalidArgumentException('Parameter must be an array or an instance of Iterable<Pair>'); } } $m = new self(); $m->hacklib_setContainer($a); return $m; } elseif (is_null($it)) { return new self(); } else { throw new \InvalidArgumentException('Parameter must be an array or an instance of Traversable'); } }