Remove redundant elseif complexity and switch to short array syntax

This commit is contained in:
Robbie Averill 2018-09-27 17:29:52 +02:00
parent adb4d1f92d
commit 594fa30b82

View File

@ -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);