From 594fa30b820fd100b3a5ba3ed67c415c40b1fefd Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 27 Sep 2018 17:29:52 +0200 Subject: [PATCH] Remove redundant elseif complexity and switch to short array syntax --- src/View/ViewableData.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/View/ViewableData.php b/src/View/ViewableData.php index 7c4d26531..f09539e63 100644 --- a/src/View/ViewableData.php +++ b/src/View/ViewableData.php @@ -108,9 +108,11 @@ class ViewableData implements IteratorAggregate // getField() isn't a field-specific getter and shouldn't be treated as such if (strtolower($property) !== 'field' && $this->hasMethod($method = "get$property")) { return true; - } elseif ($this->hasField($property)) { + } + if ($this->hasField($property)) { return true; - } elseif ($this->failover) { + } + if ($this->failover) { return isset($this->failover->$property); } @@ -129,9 +131,11 @@ class ViewableData implements IteratorAggregate // getField() isn't a field-specific getter and shouldn't be treated as such if (strtolower($property) !== 'field' && $this->hasMethod($method = "get$property")) { return $this->$method(); - } elseif ($this->hasField($property)) { + } + if ($this->hasField($property)) { return $this->getField($property); - } elseif ($this->failover) { + } + if ($this->failover) { return $this->failover->$property; } @@ -526,7 +530,7 @@ class ViewableData implements IteratorAggregate public function hasValue($field, $arguments = [], $cache = true) { $result = $this->obj($field, $arguments, $cache); - return $result->exists(); + return $result->exists(); } /** @@ -553,7 +557,7 @@ class ViewableData implements IteratorAggregate */ public function getXMLValues($fields) { - $result = array(); + $result = []; foreach ($fields as $field) { $result[$field] = $this->XML_val($field); @@ -574,7 +578,7 @@ class ViewableData implements IteratorAggregate */ public function getIterator() { - return new ArrayIterator(array($this)); + return new ArrayIterator([$this]); } // UTILITY METHODS ------------------------------------------------------------------------------------------------- @@ -642,7 +646,7 @@ class ViewableData implements IteratorAggregate */ public function CSSClasses($stopAtClass = self::class) { - $classes = array(); + $classes = []; $classAncestry = array_reverse(ClassInfo::ancestry(static::class)); $stopClasses = ClassInfo::ancestry($stopAtClass);