Process the given data against the given rules and useable data keys.

@param  array  $data
@param  array  $config
@return Payload
438112
public function process(array $data, array $config)
	{
		// Merge default or built-in configurations.
		$config = array_merge($this->config, $config);

		// Intersect the data given the with the data keys provided.
		$data = array_intersect_key($data, array_flip(array_keys($config)));

		// Validate and set our errors if they exist.
		$payload = $this->validator->validate($data, $config);

		// Return sanitized data if no validation errors exist.
		if( ! $payload->isStatus(Payload::STATUS_VALID))
		{
			return $payload;
		}

		// Grab payload data for more modification.
		$data = $payload->getData();

		if(array_key_exists(CrudRepository::PAGE_KEY, $data) && array_key_exists(CrudRepository::PER_KEY, $data))
		{
			$data[CrudRepository::PAGINATION_KEY] = [$data[CrudRepository::PAGE_KEY] => $data[CrudRepository::PER_KEY]];
		}

		if(array_key_exists(CrudRepository::FILTER_KEY, $data))
		{
			$data[CrudRepository::FILTER_KEY] = $data[CrudRepository::FILTER_KEY];
		}

		if(array_key_exists(CrudRepository::ORDER_KEY, $data))
		{
			$data[CrudRepository::ORDER_KEY] = $data[CrudRepository::ORDER_KEY];
		}

		if(array_key_exists(CrudRepository::EMBED_KEY, $data))
		{
			$data[CrudRepository::EMBED_KEY] = $data[CrudRepository::EMBED_KEY];
		}

		return new Payload($data, Payload::STATUS_VALID);
	}
823710
protected function prepareDataValue(array $config, array $data): array
    {
        $only = $config['only'] ?? null;
        $except = $config['except'] ?? null;

        if (! \is_null($only)) {
            return Arr::only($data, $only);
        } elseif (! \is_null($except)) {
            return Arr::except($data, $except);
        }

        return $data;
    }
1290752
public function validate(array $data, array $rules, array $messages = [])
	{
		// Build the validator.
		$validator = $this->validationFactory->make($data, $rules, $messages);

		// Return the errors, if any.
		if($validator->fails())
		{
			return new Payload($validator->messages(), 'invalid');
		}

		return new Payload($data, 'valid');
	}
545434
public function handle(Config $config)
    {
        $sampleOption = $this->option('sample');

        $type = 'empty';
        if( $sampleOption )
        {
            $type = 'sample';
        }

        $from = __DIR__ . '/../../resources/'.$type.'_schema.xml';
        $to = $config->get('propel.propel.paths.schemaDir') . '/' . $config->get('propel.propel.generator.schema.basename') . '.xml';

        if( ! copy($from, $to) )
        {
            throw new \Exception('Failed to copy a file "' . $from . '" to "' . $to . '"');
        }

        $content = file_get_contents($to);

        $name = $config->get('propel.propel.generator.defaultConnection');
        $content = str_replace('**NAME**', $name, $content);

        $nameSpace = $this->laravel->getNamespace() . str_replace(app_path().DIRECTORY_SEPARATOR, '', $config->get('propel.propel.paths.phpDir'));
        $content = str_replace('**NAMESPACE**', $nameSpace, $content);

        file_put_contents($to, $content);

        $this->comment(PHP_EOL . 'Create ' . $to . PHP_EOL);
    }
241382
private function parse(array $data)
    {
        $config = [];

        foreach ($data as $section => $value) {
            if (is_array($value)) {
                if (strpos($section, $this->nestSeparator) !== false) {
                    $sections = explode($this->nestSeparator, $section);
                    $config = array_merge_recursive($config, $this->buildNestedSection($sections, $value));
                } else {
                    $config[$section] = $this->parseSection($value);
                }
            } else {
                $this->parseKey($section, $value, $config);
            }
        }

        return $config;
    }
1017491
protected function isValidData($config)
    {
        $valid = true;
        foreach ($config as $k => $v) {
            if (!($this->isValidKey($k) && $this->isValidValue($v))) {
                $valid = false;
                break;
            }
        }
        return $valid;
    }
2120
protected function convertToExcel(array $data, array $config): Collection
    {
        $uses = $config['uses'] ?? 'data';
        $content = $data[$uses] ?? [];

        if ($content instanceof Arrayable) {
            $content = $content->toArray();
        }

        return Collection::make(\array_map([$this, 'transformToArray'], $content));
    }
967094
public function parseString($config)
    {
        libxml_use_internal_errors(true);
        $data = simplexml_load_string($config, null, LIBXML_NOERROR);
        return (array)$this->parse($data);
    }
787219
public function plainText(MailConfig $config, array $data)
    {
        $plainTemplate = $config->template().$this->plainSuffix;

        if ($this->views->exists($plainTemplate)) {
            return $this->views->make($plainTemplate, $data)->render();
        }

        if (!$this->htmlPlainConverter) {
            return '';
        }

        return call_user_func($this->htmlPlainConverter, $this->html($config, $data),  $data);
    }
1132006
public function findOrAddNew($data = array(), $config = array())
    {
        $entity = $this->find($data);

        if (!$entity) {
            $entity = $this->addNew($data, $config);
        }

        return $entity;
    }
646715
public function json( array $config = [] ) {
        $options = isset($config['big_int_strings']) ? JSON_BIGINT_AS_STRING : 0;
        return json_decode($this->response->getBody(), false, 512, $options);
    }
7490
public static function hydrate(array $data, ByConfigBuilder $config)
    {
        // When entity is not available. Only use the collection to set the data
        if ($config->getEntity() === false) {
            return $config->getCollectionEntity($data);
        }

        // When there is no collection specified. Make sure there will be an array to iterate through
        if ($config->isCollection() === false) {
            $data = array($data);
        }

        $rows = array();

        // Loop through the data
        foreach ($data as $index => $row) {
            $rows[$index] = $entity = $config->getEntity();

            foreach ($row as $field => $value) {
                // Skip field if not defined in the configuration
                if ($config->hasField($field) === false) {
                    $catchAll = $config->getCatchAllSetter();

                    if ($catchAll !== null) {
                        call_user_func(array($entity, $catchAll), $field, $value);
                    }

                    continue;
                }

                $callable = array($entity, $config->getSetter($field));

                if ($config->isInclude($field) === true) {
                    if (is_array($value) === false) {
                        throw new Exception\HydrateFailed(sprintf(static::$exceptions[1], $field, gettype($value)));
                    }

                    $value = static::hydrate($value, $config->getInclude($field));
                } else if ($config->getFormatter($field) !== null) {
                    $value = call_user_func($config->getFormatter($field), $value);
                }

                // Add the value
                call_user_func($callable, $value);
            }
        }

        return ($config->isCollection() === true) ? $config->getCollectionEntity($rows) : $entity;
    }
1282653
public static function getChannel(array $config = []): Channel
    {
        $channel = new Channel();
        $channel->setHandler(static::getHandler($config['handler'] ?? []));
        $channel->setFormatter(static::getFormatter($config['formatter'] ?? []));

        return $channel;
    }
393400
public function flash($config = array())
    {
        $data = $this->_template->getData();

        if (isset($data['flash']) && $data['flash']->message) {
            $message = array_merge((array) $data['flash']->getMessage(true), $config);
            return $this->message($message['message'], $message);
        }
    }
297348
protected function config($data = []) {

		if(null === $data) {
			$data = [];
		}

		if(false === is_array($data)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR);
		}

		$module = Router :: getRoute() -> getModule();
		
		return Config :: get(array_merge([$module], $data));
	}
566915
public function execCurl(array $config)
    {
        $config[CURLOPT_VERBOSE]        = false;
        $config[CURLOPT_SSL_VERIFYPEER] = false;
        $config[CURLOPT_RETURNTRANSFER] = true;

        if (defined('CURLOPT_IPRESOLVE')) // PHP5.3
        {
            $config[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
        }

        $ch = curl_init();

        foreach ($config as $key => $value) {
            curl_setopt($ch, $key, $value);
        }

        $result      = curl_exec($ch);
        $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $error       = curl_error($ch);
        $error_code  = curl_errno($ch);

        curl_close($ch);

        return [$result, $status_code, $error, $error_code];
    }
1206294
private function convert(array $config)
    {
        foreach ($config as $index => $data) {
            if (is_array($data)) {
                $config[$index] = new Config($data);
            }
        }

        return $config;
    }