<?php
/**
 * Created by IntelliJ IDEA.
 * User: victor
 * Date: 31.10.17
 * Time: 11:03
 */

class DoctrineCollectionHelper
{
    protected $collect;
    
    public static function make(Doctrine_Collection $collect)
    {
        return new self($collect);
    }
    
    public function __construct(Doctrine_Collection $collect)
    {
        $this->collect = clone $collect;
    }
    
    /**
     * @param array $arrFields array(fieldName => value)     *
     * @return Doctrine_Record|null
     */
    public function find($arrFields)
    {
        $result = null;
        /**@var Doctrine_Record $record*/
        foreach ($this->collect as $record) {
            $flag = true;
            foreach ($arrFields as $fieldName => $value) {
                if($record->get($fieldName))
                {
                
                }
            }
            if($flag) {
              $result = $record;
              break;
            }
        }
        return $result;
    }
    
    
}