Skip to content

Commit

Permalink
feat: Nested can now be iterated
Browse files Browse the repository at this point in the history
  • Loading branch information
taka-oyama committed Aug 11, 2021
1 parent 7630e93 commit c6ca2c1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Colopl/Spanner/Query/Nested.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

namespace Colopl\Spanner\Query;

use ArrayIterator;
use Illuminate\Contracts\Support\Arrayable;
use IteratorAggregate;

/**
* @internal use only for UNNESTing
*/
class Nested implements Arrayable
class Nested implements Arrayable, IteratorAggregate
{
/**
* @var array
Expand All @@ -42,8 +44,16 @@ public function __construct($array)
/**
* @return array
*/
public function toArray()
public function toArray(): array
{
return array_values($this->array);
}

/**
* @return ArrayIterator
*/
public function getIterator(): ArrayIterator
{
return new ArrayIterator($this->array);
}
}

0 comments on commit c6ca2c1

Please sign in to comment.