Skip to content

Commit c35b29d

Browse files
janpechamibk
authored andcommitted
Query: Iterating over Query object throws exception
1 parent f1067e9 commit c35b29d

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the LeanMapperQuery extension
5+
* for the Lean Mapper library (http://leanmapper.com)
6+
*/
7+
8+
namespace LeanMapperQuery\Exception;
9+
10+
class NotImplementedException extends Exception
11+
{
12+
}

LeanMapperQuery/Query.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use LeanMapperQuery\Exception\InvalidStateException;
2020
use LeanMapperQuery\Exception\MemberAccessException;
2121
use LeanMapperQuery\Exception\NonExistingMethodException;
22+
use LeanMapperQuery\Exception\NotImplementedException;
2223

2324
/**
2425
* @author Michal Bohuslávek
@@ -30,7 +31,7 @@
3031
* @method Query limit(int $limit)
3132
* @method Query offset(int $offset)
3233
*/
33-
class Query implements IQuery
34+
class Query implements IQuery, \Iterator
3435
{
3536
/** @var string */
3637
private static $defaultPlaceholder = '?';
@@ -576,4 +577,31 @@ private function commandOffset($offset)
576577
$this->fluent->offset($offset);
577578
}
578579

580+
//////////////////// Iterator //////////////////////
581+
582+
public function current()
583+
{
584+
throw new NotImplementedException("Query object is not iterable.");
585+
}
586+
587+
public function next()
588+
{
589+
throw new NotImplementedException("Query object is not iterable.");
590+
}
591+
592+
public function rewind()
593+
{
594+
throw new NotImplementedException("Query object is not iterable.");
595+
}
596+
597+
public function key()
598+
{
599+
throw new NotImplementedException("Query object is not iterable.");
600+
}
601+
602+
public function valid()
603+
{
604+
throw new NotImplementedException("Query object is not iterable.");
605+
}
606+
579607
}

0 commit comments

Comments
 (0)