From 89a9f40956595f7446cf687a22c791e65d413e19 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sun, 16 Oct 2016 09:45:18 +0200 Subject: [PATCH] Check if component/macro exists instead of relying on exceptions --- src/FormBuilder.php | 8 ++------ src/HtmlBuilder.php | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/FormBuilder.php b/src/FormBuilder.php index 4e7cf0f..f014b32 100644 --- a/src/FormBuilder.php +++ b/src/FormBuilder.php @@ -1197,16 +1197,12 @@ class FormBuilder */ public function __call($method, $parameters) { - try { + if (static::hasComponent($method)) { return $this->componentCall($method, $parameters); - } catch (BadMethodCallException $e) { - // } - try { + if (static::hasMacro($method)) { return $this->macroCall($method, $parameters); - } catch (BadMethodCallException $e) { - // } throw new BadMethodCallException("Method {$method} does not exist."); diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php index 7306fc4..95e9fb7 100755 --- a/src/HtmlBuilder.php +++ b/src/HtmlBuilder.php @@ -546,16 +546,12 @@ class HtmlBuilder */ public function __call($method, $parameters) { - try { + if (static::hasComponent($method)) { return $this->componentCall($method, $parameters); - } catch (BadMethodCallException $e) { - // } - try { + if (static::hasMacro($method)) { return $this->macroCall($method, $parameters); - } catch (BadMethodCallException $e) { - // } throw new BadMethodCallException("Method {$method} does not exist.");