Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
aryelgois committed Jul 8, 2018
2 parents 0dc32ae + 951d165 commit 0cfe049
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]


## [5.1.2] - 2018-07-08

### Changed
- ModelIterator now implements Countable


## [5.1.1] - 2018-07-07

### Changed
Expand Down Expand Up @@ -267,7 +273,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- DatabaseObject.php


[Unreleased]: https://github.com/aryelgois/Medools/compare/v5.1.1...develop
[Unreleased]: https://github.com/aryelgois/Medools/compare/v5.1.2...develop
[5.1.2]: https://github.com/aryelgois/Medools/compare/v5.1.1...v5.1.2
[5.1.1]: https://github.com/aryelgois/Medools/compare/v5.1.0...v5.1.1
[5.1.0]: https://github.com/aryelgois/Medools/compare/v5.0.0...v5.1.0
[5.0.0]: https://github.com/aryelgois/Medools/compare/v4.3.0...v5.0.0
Expand Down
12 changes: 11 additions & 1 deletion src/ModelIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @license MIT
* @link https://www.github.com/aryelgois/Medools
*/
class ModelIterator implements \Iterator
class ModelIterator implements \Iterator, \Countable
{
/**
* List PRIMARY KEYS for $model_class
Expand Down Expand Up @@ -63,6 +63,16 @@ public function __construct(string $model_class, $where = [])
$this->list = $model_class::dump($where, $model_class::PRIMARY_KEY);
}

/**
* Counts how many Models are in this Iterator
*
* @return int
*/
public function count()
{
return count($this->list);
}

/**
* Loads the model with the current pointened PRIMARY KEY and returns it
*
Expand Down

0 comments on commit 0cfe049

Please sign in to comment.