mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 01:31:45 +01:00
38 lines
840 B
PHP
38 lines
840 B
PHP
<?php
|
|
|
|
/**
|
|
* (c) Meritoo.pl, http://www.meritoo.pl
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Meritoo\Common\Utilities;
|
|
|
|
use Generator;
|
|
|
|
/**
|
|
* Useful methods for the Generator class (only static functions)
|
|
*
|
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
|
* @copyright Meritoo.pl
|
|
*/
|
|
class GeneratorUtility
|
|
{
|
|
/**
|
|
* Returns elements of generator
|
|
*
|
|
* @param Generator $generator The generator who elements should be returned
|
|
* @return array
|
|
*/
|
|
public static function getGeneratorElements(Generator $generator)
|
|
{
|
|
$elements = [];
|
|
|
|
for (; $generator->valid(); $generator->next()) {
|
|
$elements[] = $generator->current();
|
|
}
|
|
|
|
return $elements;
|
|
}
|
|
}
|