mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-02 06:09:00 +02:00
Remove redundant elseif complexity and switch to short array syntax
This commit is contained in:
parent
adb4d1f92d
commit
594fa30b82
@ -108,9 +108,11 @@ class ViewableData implements IteratorAggregate
|
|||||||
// getField() isn't a field-specific getter and shouldn't be treated as such
|
// getField() isn't a field-specific getter and shouldn't be treated as such
|
||||||
if (strtolower($property) !== 'field' && $this->hasMethod($method = "get$property")) {
|
if (strtolower($property) !== 'field' && $this->hasMethod($method = "get$property")) {
|
||||||
return true;
|
return true;
|
||||||
} elseif ($this->hasField($property)) {
|
}
|
||||||
|
if ($this->hasField($property)) {
|
||||||
return true;
|
return true;
|
||||||
} elseif ($this->failover) {
|
}
|
||||||
|
if ($this->failover) {
|
||||||
return isset($this->failover->$property);
|
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
|
// getField() isn't a field-specific getter and shouldn't be treated as such
|
||||||
if (strtolower($property) !== 'field' && $this->hasMethod($method = "get$property")) {
|
if (strtolower($property) !== 'field' && $this->hasMethod($method = "get$property")) {
|
||||||
return $this->$method();
|
return $this->$method();
|
||||||
} elseif ($this->hasField($property)) {
|
}
|
||||||
|
if ($this->hasField($property)) {
|
||||||
return $this->getField($property);
|
return $this->getField($property);
|
||||||
} elseif ($this->failover) {
|
}
|
||||||
|
if ($this->failover) {
|
||||||
return $this->failover->$property;
|
return $this->failover->$property;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,7 +530,7 @@ class ViewableData implements IteratorAggregate
|
|||||||
public function hasValue($field, $arguments = [], $cache = true)
|
public function hasValue($field, $arguments = [], $cache = true)
|
||||||
{
|
{
|
||||||
$result = $this->obj($field, $arguments, $cache);
|
$result = $this->obj($field, $arguments, $cache);
|
||||||
return $result->exists();
|
return $result->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -553,7 +557,7 @@ class ViewableData implements IteratorAggregate
|
|||||||
*/
|
*/
|
||||||
public function getXMLValues($fields)
|
public function getXMLValues($fields)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = [];
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$result[$field] = $this->XML_val($field);
|
$result[$field] = $this->XML_val($field);
|
||||||
@ -574,7 +578,7 @@ class ViewableData implements IteratorAggregate
|
|||||||
*/
|
*/
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
return new ArrayIterator(array($this));
|
return new ArrayIterator([$this]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// UTILITY METHODS -------------------------------------------------------------------------------------------------
|
// UTILITY METHODS -------------------------------------------------------------------------------------------------
|
||||||
@ -642,7 +646,7 @@ class ViewableData implements IteratorAggregate
|
|||||||
*/
|
*/
|
||||||
public function CSSClasses($stopAtClass = self::class)
|
public function CSSClasses($stopAtClass = self::class)
|
||||||
{
|
{
|
||||||
$classes = array();
|
$classes = [];
|
||||||
$classAncestry = array_reverse(ClassInfo::ancestry(static::class));
|
$classAncestry = array_reverse(ClassInfo::ancestry(static::class));
|
||||||
$stopClasses = ClassInfo::ancestry($stopAtClass);
|
$stopClasses = ClassInfo::ancestry($stopAtClass);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user