Adjusting interface and implementation to use \Iterator instead of array

This commit is contained in:
Ferdinand Kuhl 2021-06-08 18:35:42 +02:00
parent 6339e96084
commit 27bfb049f3
2 changed files with 3 additions and 7 deletions

View file

@ -22,5 +22,5 @@ interface ServiceInterface
*
* @return array|\Iterator
*/
public function getItems(string $forPath = null): array;
public function getItems(string $forPath = null): \Iterator;
}

View file

@ -32,11 +32,7 @@ class SettingsService implements ServiceInterface
*/
protected array $items = array();
/**
* @param string|null $forPath
* @return array
*/
public function getItems(string $forPath = null): array
public function getItems(string $forPath = null): \Iterator
{
if ($forPath) {
$items = &$this->menuConfiguration[$forPath];
@ -51,6 +47,6 @@ class SettingsService implements ServiceInterface
}
);
}
return $items;
return new \ArrayIterator($items);
}
}