src/SnooPHP/Model/Collection.php
public function find($criteria)
	{
		if (!$criteria)
		{
			error_log("collection error: no criteria specified");
			return null;
		}

		else if (is_callable($criteria))
		{
			foreach ($this->models as $model)
				if ($criteria($model)) return $model;
		}
		else if (is_a($criteria, "SnooPHP\Model\Model"))
		{
			foreach ($this->models as $i => $model)
				if ($model == $criteria) return $i;
		}

		return null;
	}
public function find($criteria)
	{
		if (!$criteria)
		{
			error_log("collection error: no criteria specified");
			return null;
		}

		else if (is_callable($criteria))
		{
			foreach ($this->models as $model)
				if ($criteria($model)) return $model;
		}
		else if (is_a($criteria, "SnooPHP\Model\Model"))
		{
			foreach ($this->models as $i => $model)
				if ($model == $criteria) return $i;
		}

		return null;
	}
public function find ( $ criteria ) { if ( ! $ criteria ) { error_log ( "collection error: no criteria specified" ) ; return null ; } else if ( is_callable ( $ criteria ) ) { foreach ( $ this -> models as $ model ) if ( $ criteria ( $ model ) ) return $ model ; } else if ( is_a ( $ criteria , "SnooPHP\Model\Model" ) ) { foreach ( $ this -> models as $ i => $ model ) if ( $ model == $ criteria ) return $ i ; } return null ; }
Find an element

@param Callable|Model $criteria model to match or callable called on every element (return true if element match the criteria)

@return Model|int|null	if model is given, return index or null if not found.
If callable given, return matching element or null if none found.
In any case returns only a single result
Find an element