/** * Call to undefined method. * * @param string method name * @param array arguments * @return mixed * @throws MemberAccessException */ public function __call($name, $args) { $function = 'image' . $name; if (function_exists($function)) { foreach ($args as $key => $value) { if ($value instanceof self) { $args[$key] = $value->getImageResource(); } elseif (is_array($value) && isset($value['red'])) { // rgb $args[$key] = imagecolorallocatealpha($this->getImageResource(), $value['red'], $value['green'], $value['blue'], $value['alpha']); } } array_unshift($args, $this->getImageResource()); $res = call_user_func_array($function, $args); return is_resource($res) && get_resource_type($res) === 'gd' ? $this->setImageResource($res) : $res; } return parent::__call($name, $args); }
/** * Call to undefined method. * * @param string method name * @param array arguments * @return mixed * @throws MemberAccessException */ public function __call($method, $args) { if (method_exists($this->getImageResource(), $method)) { $result = call_user_func_array([$this->getImageResource(), $method], $args); if (is_bool($result)) { return $this; } else { return $result; } } return parent::__call($method, $args); }