Create object and set params

@param string $className
@param array $params
@return \pwf\helpers\className
429311
public static function createObject($className, array $params = [])
    {
        $result = new $className;
        foreach ($params as $key => $val) {
            $methodName = 'set'.ucfirst($key);
            if (method_exists($result, $methodName)) {
                $result->$methodName($val);
            }
        }
        return $result;
    }
965041
public function set($className, $values) {
        if (!isset($this->options[$className])) {
            $this->options[$className] = array();
        }
        foreach ($values as $k => $v) {
            $this->options[$className][$k] = $v;

        }
        return $this;
    }
187750
public function setClassParameters($classParams)
    {
        $object = $this->getObject();
        $tableName = $object->getCoreTableName();
        $values = array();
        foreach ($classParams as $sParamKey => $paramValue) {
            if (is_int($sParamKey)) {
                $fieldName = $this->_getFieldName($tableName, $paramValue);
                $values[$paramValue] = $object->$fieldName->value;
            } else {
                $fieldName = $this->_getFieldName($tableName, $sParamKey);
                if (is_string($paramValue)) {
                    $paramValue = html_entity_decode($paramValue);
                }
                $object->$fieldName = new \OxidEsales\Eshop\Core\Field($paramValue);
            }
        }

        return $values;
    }
604630
public function addClass( $className, $parameters = array() )
	{
		$object	= Alg_Object_Factory::createObject( $className, $parameters );
		$this->addObject( $object );
	}
608413
public function create(string $className, string $typeName): Type
    {
        $typeName = Utils::getTypeName($className);
        $description = $this->getDescription($className);

        $fieldsGetter = function () use ($className): array {
            $factory = new OutputFieldsConfigurationFactory($this->types, $this->entityManager);
            $configuration = $factory->create($className);

            return $configuration;
        };

        return new ObjectType([
            'name' => $typeName,
            'description' => $description,
            'fields' => $fieldsGetter,
        ]);
    }
1027861
protected function prepareToSave($classname, array $params = [], array $paramsFromSession = null)
    {
        $column = $params['column'];
        $return = [];
        if (is_null($paramsFromSession)) {
            $return[$column]['classname'] = $classname;
            $return[$column]['values']    = [$params['value']];
            //this chunk of code will automatically add custom $params values
            //everything else then 'value' will be saved in session
            //this allow developer to send custom parameters through request
            foreach ($params as $key => $value) {
                if ($key == 'value') {
                    continue;
                }
                $return[$column][$key . 's'] = [$params[$key]];
            }
        } elseif (isset($paramsFromSession[$column])) {
            $paramsFromSession[$column]['values'][] = $params['value'];
            //this chunk of code will automatically add custom $params values
            //everything else then 'value' will be add to already existing key in session and saved
            //this allow developer to send custom parameters through request
            foreach ($params as $key => $value) {
                if ($key == 'value') {
                    continue;
                }
                $paramsFromSession[$column][$key . 's'][] = $params[$key];
                $return[$column][$key . 's']              = $paramsFromSession[$column][$key . 's'];
            }

            $return[$column]['values']    = $paramsFromSession[$column]['values'];
            $return[$column]['classname'] = $classname;
        } else {
            $return                       = $paramsFromSession;
            $return[$column]['classname'] = $classname;
            $return[$column]['values']    = [$params['value']];

            //this chunk of code will automatically add custom $params values
            //everything else then 'value' will be saved in session
            //this allows developer to send custom parameters through request 
            foreach ($params as $key => $value) {
                if ($key == 'value') {
                    continue;
                }
                $return[$column][$key . 's'] = [$params[$key]];
            }
        }
        if (!empty($paramsFromSession)) {
            foreach ($paramsFromSession as $storedColumn => $config) {
                if ($storedColumn == $column) {
                    continue;
                }
                $return[$storedColumn] = $config;
            }
        }
        return $return;
    }
364135
public function create($methodName, $params)
    {
        $newInstance = clone $this->injectorPrototype;

        if (!is_array($params)) {
            $params = array($params);
        }

        return $newInstance->setMethodName($methodName)->setParams($params);
    }
45499
public static function create($params = null, $apiKey = null)
    {
        $class = get_class();
        return self::_scopedCreate($class, $params, $apiKey);
    }
520006
public static function createNewObject($className, $args = null)
    {
        $mock = self::getMock(self::$injectedObjects, 'object', $className);
        if ($mock !== null)
        {
            return $mock;
        }

        if ($args === null)
        {
            return new $className();
        }

        // we need to pass arguments which requires reflection
        $reflection = new ReflectionClass($className);
        return $reflection->newInstanceArgs($args);
    }
243391
public function build($className , array $options = [] )
    {
        if (is_a($className, Configurable::class, true)) {
            $service = new $className($options);
            $this->propagate($service);
            return $service;
        }

        throw new ServiceNotFoundException($className);
    }
957669
public static function instantiate($className, array $namedArguments)
    {
        $reflectionClass = new ReflectionClass($className);
        $parameters = $reflectionClass->getConstructor()->getParameters();

        $positionalDefaultFilledArguments = array();
        foreach ($parameters as $parameter) {
            // Do we have an argument set? If so use that.
            if (isset($namedArguments[$parameter->name])) {
                $positionalDefaultFilledArguments[] = $namedArguments[$parameter->name];
                continue;
            }

            // Otherwise use the default.
            $positionalDefaultFilledArguments[] = $parameter->getDefaultValue();
        }

        return $reflectionClass->newInstanceArgs($positionalDefaultFilledArguments);
    }
1112340
public function createEvent($eventName, array $params = array())
    {
        $class = $this->eventClass;
        return new $class($this->sender, $this->prefix . $eventName, $params);
    }
1278520
public static function create(array $params)
  {
    $create = R::dispense(self::classRefactor(get_called_class()));
    foreach ($params as $param => $value) {
      $create->$param = $value;
    }
    $create->created_at = time();
    $create->updated_at = time();
    R::store($create);
  }
444855
protected function createProjectClass($className)
    {
        $arguments = func_get_args();
        array_shift($arguments);

        return $this->_projectLoader->createClass($className, $arguments);
    }
871188
protected function createFormInstance(string $className, array $params)
    {
        $result = new $className ($this->getTranslator(), $this->getValidator(), $this->getOptions(), $params);

        return $result;
    }
631872
protected function buildParameters($className)
    {
        /** @var \Pok\PoolDBM\Mapping\ClassMetadata $metadata */
        $metadata = $this->getModelManager()->getClassMetadata($className);

        $managers = array();
        foreach ($metadata->getFieldMappings() as $model) {

            $managers[$model->getManagerName()] = array(
                'namespace' => '\\' . $model->getName(),
                'methods'   => array()
            );

            $fields = $model->getFields();
            if ($metadata->getManagerIdentifier() === $model->getManagerName()) {
                $fields[] = $metadata->getFieldIdentifier();
            }

            $pattern = self::patternDeclared($fields);

            $refl = new \ReflectionClass($model->getName());
            foreach ($refl->getMethods() as $method) {
                if (!$method->isPublic() || $method->isStatic() || $method->isConstructor() || $method->isDestructor() || $method->isAbstract()) {
                    continue;
                }

                preg_match($pattern, $method->getName(), $matches);
                if (empty($matches)) {
                    continue;
                }

                $arg = array(
                    'comment'    => $method->getDocComment(),
                    'name'       => $method->getName(),
                    'type'       => in_array($matches[1], array('get','is','has','all','check')) ? 'getter' : 'setter',
                    'arguments'  => Reflector::parameters($method->getParameters()),
                    'parameters' => $method->getParameters()
                );

                $managers[$model->getManagerName()]['methods'][] = $arg;
            }
        }

        $associations = new Bag();
        foreach ($metadata->getAssociationDefinitions() as $definition) {
            if ($definition->isMany()) {
                $associations->many[$definition->getField()] = array(
                    'fields'    => $definition->getReferences(),
                    'className' => $definition->getTargetMultiModel()
                );
            } else {
                $associations->one[$definition->getField()] = array(
                    'className' => $definition->getTargetMultiModel()
                );
            }
        }

        $occ = strrpos($metadata->getName(), '\\');

        return array(
            'model_namespace'   => substr($metadata->getName(), 0, $occ),
            'model_name'        => substr($metadata->getName(), $occ + 1),
            'managers'          => $managers,
            'associations'      => $associations
        );
    }
72887
private function createObject(string $className, array $data)
    {
        $repository = $this->objectManager->getRepository($className);

        $object = $repository->create($className);

        if ($object instanceof NotifyPropertyChanged) {
            $object->addPropertyChangedListener($this);
        }

        $this->eventDispatcher->dispatchPreLoad($object, $data);

        $repository->hydrate($object, $data);

        $this->eventDispatcher->dispatchPostLoad($object);

        $this->objectIdentityMap->addToIdentityMap($object, $data);

        return $object;
    }