Phalcon\Mvc\Model\EagerLoading\Loader::__construct PHP Method

__construct() public method

public __construct ( Phalcon\Mvc\ModelInterface | Phalcon\Mvc\ModelInterface[] | Phalcon\Mvc\Model\Resultset\Simple $from )
$from Phalcon\Mvc\ModelInterface | Phalcon\Mvc\ModelInterface[] | Phalcon\Mvc\Model\Resultset\Simple
    public function __construct($from)
    {
        $error = false;
        $className = null;
        $arguments = array_slice(func_get_args(), 1);
        if (!$from instanceof ModelInterface) {
            if (!$from instanceof Simple) {
                if (($fromType = gettype($from)) !== 'array') {
                    if (null !== $from && $fromType !== 'boolean') {
                        $error = true;
                    } else {
                        $from = null;
                    }
                } else {
                    $from = array_filter($from);
                    if (empty($from)) {
                        $from = null;
                    } else {
                        foreach ($from as $el) {
                            if ($el instanceof ModelInterface) {
                                if ($className === null) {
                                    $className = get_class($el);
                                } else {
                                    if ($className !== get_class($el)) {
                                        $error = true;
                                        break;
                                    }
                                }
                            } else {
                                $error = true;
                                break;
                            }
                        }
                    }
                }
            } else {
                $prev = $from;
                $from = [];
                foreach ($prev as $record) {
                    $from[] = $record;
                }
                if (empty($from)) {
                    $from = null;
                } else {
                    $className = get_class($record);
                }
            }
            $this->mustReturnAModel = false;
        } else {
            $className = get_class($from);
            $from = [$from];
            $this->mustReturnAModel = true;
        }
        if ($error) {
            throw new \InvalidArgumentException(static::E_INVALID_SUBJECT);
        }
        $this->subject = $from;
        $this->subjectClassName = $className;
        $this->eagerLoads = $from === null || empty($arguments) ? [] : static::parseArguments($arguments);
    }