public static function prepareConstructorArgs(\ReflectionClass $reflectionClass, array $params)
    {

        // prepare the array for the initialized arguments
        $initializedParams = array();

        // prepare the array for the arguments in camel case (in configuration we use a '-' notation)
        $paramsInCamelCase = array();

        // convert the configuration keys to camelcase
        foreach ($params as $key => $value) {
            $paramsInCamelCase[lcfirst(str_replace('-', '', ucwords($key, '-')))] = $value;
        }

        // load the constructor's reflection parameters
        $constructorParameters = $reflectionClass->getConstructor()->getParameters();

        // prepare the arguments by applying the values from the configuration
        /** @var \ReflectionParameter $reflectionParameter */
        foreach ($constructorParameters as $reflectionParameter) {
            if (isset($paramsInCamelCase[$paramName = $reflectionParameter->getName()])) {
                $initializedParams[$paramName] = $paramsInCamelCase[$paramName];
            } elseif ($reflectionParameter->isOptional()) {
                $initializedParams[$paramName] = $reflectionParameter->getDefaultValue();
            } else {
                $initializedParams[$paramName] = null;
            }
        }

        // return the array with the prepared arguments
        return $initializedParams;
    }
public static function prepareConstructorArgs(\ReflectionClass $reflectionClass, array $params)
    {

        // prepare the array for the initialized arguments
        $initializedParams = array();

        // prepare the array for the arguments in camel case (in configuration we use a '-' notation)
        $paramsInCamelCase = array();

        // convert the configuration keys to camelcase
        foreach ($params as $key => $value) {
            $paramsInCamelCase[lcfirst(str_replace('-', '', ucwords($key, '-')))] = $value;
        }

        // load the constructor's reflection parameters
        $constructorParameters = $reflectionClass->getConstructor()->getParameters();

        // prepare the arguments by applying the values from the configuration
        /** @var \ReflectionParameter $reflectionParameter */
        foreach ($constructorParameters as $reflectionParameter) {
            if (isset($paramsInCamelCase[$paramName = $reflectionParameter->getName()])) {
                $initializedParams[$paramName] = $paramsInCamelCase[$paramName];
            } elseif ($reflectionParameter->isOptional()) {
                $initializedParams[$paramName] = $reflectionParameter->getDefaultValue();
            } else {
                $initializedParams[$paramName] = null;
            }
        }

        // return the array with the prepared arguments
        return $initializedParams;
    }
public static function prepareConstructorArgs ( \ ReflectionClass $ reflectionClass , array $ params ) { // prepare the array for the initialized arguments $ initializedParams = array ( ) ; // prepare the array for the arguments in camel case (in configuration we use a '-' notation) $ paramsInCamelCase = array ( ) ; // convert the configuration keys to camelcase foreach ( $ params as $ key => $ value ) { $ paramsInCamelCase [ lcfirst ( str_replace ( '-' , '' , ucwords ( $ key , '-' ) ) ) ] = $ value ; } // load the constructor's reflection parameters $ constructorParameters = $ reflectionClass -> getConstructor ( ) -> getParameters ( ) ; // prepare the arguments by applying the values from the configuration /** @var \ReflectionParameter $reflectionParameter */ foreach ( $ constructorParameters as $ reflectionParameter ) { if ( isset ( $ paramsInCamelCase [ $ paramName = $ reflectionParameter -> getName ( ) ] ) ) { $ initializedParams [ $ paramName ] = $ paramsInCamelCase [ $ paramName ] ; } elseif ( $ reflectionParameter -> isOptional ( ) ) { $ initializedParams [ $ paramName ] = $ reflectionParameter -> getDefaultValue ( ) ; } else { $ initializedParams [ $ paramName ] = null ; } } // return the array with the prepared arguments return $ initializedParams ; }
Prepare's the arguments for the passed reflection class by applying the values from the passed configuration array
to the apropriate arguments. If no value is found in the configuration, the constructor argument's default value is
used.

@param \ReflectionClass $reflectionClass The reflection class to prepare the arguments for
@param array            $params          The constructor arguments from the configuration

@return array The array with the constructor arguements
Prepare s the arguments for the passed reflection class by applying the values from the passed configuration array to the apropriate arguments . If no value is found in the configuration the constructor argument s default value is used .