diff --git a/src/RowCollection.php b/src/RowCollection.php index 0619df3..fcecc22 100644 --- a/src/RowCollection.php +++ b/src/RowCollection.php @@ -325,7 +325,7 @@ public function add($rows) * @param mixed $value The value to filter * @param bool $strict Strict mode * - * @return RowInterface The rows found + * @return RowCollection */ public function filter($name, $value, $strict = true) { @@ -340,6 +340,24 @@ public function filter($name, $value, $strict = true) return $this->entity->createCollection($rows); } + /** + * Find a row by a value. + * + * @param string $name The value name + * @param mixed $value The value to filter + * @param bool $strict Strict mode + * + * @return Row|null The rows found + */ + public function find($name, $value, $strict = true) + { + foreach ($this->rows as $row) { + if (($row->$name === $value) || (!$strict && $row->$name == $value) || (is_array($value) && in_array($row->$name, $value, $strict))) { + return $row; + } + } + } + /** * Distribute a rowcollection througth all rows. *