Spot\Entity\Collection::filter PHP 메소드

filter() 공개 메소드

Runs a function on every object in the query, returning an array containing every object for which the function returns true.
public filter ( $func ) : mixed
리턴 mixed An array of Entity objects
    public function filter($func)
    {
        $ret = new static();
        foreach ($this as $obj) {
            if ($func($obj)) {
                $ret->add($obj);
            }
        }
        return $ret;
    }