PHP7 Strategy

This commit is contained in:
Dominik Liebler
2016-09-22 11:02:03 +02:00
parent 9b9eee5a4c
commit 36f3df8fbb
5 changed files with 47 additions and 53 deletions

View File

@@ -17,30 +17,24 @@ class ObjectCollection
/**
* @param array $elements
*/
public function __construct(array $elements = array())
public function __construct(array $elements = [])
{
$this->elements = $elements;
}
/**
* @return array
*/
public function sort()
public function sort(): array
{
if (!$this->comparator) {
throw new \LogicException('Comparator is not set');
}
$callback = array($this->comparator, 'compare');
uasort($this->elements, $callback);
uasort($this->elements, [$this->comparator, 'compare']);
return $this->elements;
}
/**
* @param ComparatorInterface $comparator
*
* @return void
*/
public function setComparator(ComparatorInterface $comparator)
{