From 184018868518fbb5f77cae646e4bb26f3777ec09 Mon Sep 17 00:00:00 2001 From: Ben Speakman Date: Thu, 16 Apr 2015 14:10:43 +0100 Subject: [PATCH] Implement __isset() magic method This is primarily to allow Twig to access the properties of Item http://twig.sensiolabs.org/doc/recipes.html#using-dynamic-object-properties --- src/Moltin/Cart/Item.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Moltin/Cart/Item.php b/src/Moltin/Cart/Item.php index 418c8eb..42e32e6 100755 --- a/src/Moltin/Cart/Item.php +++ b/src/Moltin/Cart/Item.php @@ -62,6 +62,19 @@ public function __get($param) return array_key_exists($param, $this->data) ? $this->data[$param] : null; } + + /** + * Return the existence of protected methods + * + * @param any $param + * @return mixed + */ + public function __isset($param) + { + if ($param == 'identifier') return true; + + return array_key_exists($param, $this->data) ? true : false; + } /** * Update data array using set magic method