src/ArrayObject.php
public function createModel($class, $attributes = [])
    {
        /** @var ActiveRecord $model */
        $model = Yii::createObject($class);

        if (!$model || !is_a($model, BaseActiveRecord::className())) {
            throw new Exception('This class is not supported for creating from ArrayObject. Only subclasses of yii\base\Model are supported');
        }

        if ($attributes && !empty($attributes)) {
            foreach ($attributes as $attribute) {
                $model->setAttribute($attribute, $this->{$attribute});
            }
        } else {
            $model->setAttributes($this->getValues(), true);
        }

        return $model;
    }
public function createModel($class, $attributes = [])
    {
        /** @var ActiveRecord $model */
        $model = Yii::createObject($class);

        if (!$model || !is_a($model, BaseActiveRecord::className())) {
            throw new Exception('This class is not supported for creating from ArrayObject. Only subclasses of yii\base\Model are supported');
        }

        if ($attributes && !empty($attributes)) {
            foreach ($attributes as $attribute) {
                $model->setAttribute($attribute, $this->{$attribute});
            }
        } else {
            $model->setAttributes($this->getValues(), true);
        }

        return $model;
    }
@param       $class
@param array $attributes

@return object
@throws Exception
@throws \yii\base\InvalidConfigException