Complete and validates given parameters with default settings

@param array $params Parameters to be cleaned

@return array Cleaned parameters

@throws \InvalidArgumentException
354278
protected function configure(array $params)
    {
        $required = array('hostname', 'base_dn');
        $missing = array();
        foreach ($required as $key) {
            if (! array_key_exists($key, $params)) {
                $missing[] = $key;
            }
        }
        if (count($missing) > 0) {
            throw new \InvalidArgumentException(
                'Required parameters missing: ' . implode(', ', $missing)
            );
        }

        $idx = strpos($params['hostname'], '://');
        $enforceSSL = false;
        if (false !== $idx) {
            $prefix = strtolower(substr($params['hostname'], 0, $idx));
            if ($prefix === 'ldaps') {
                $enforceSSL = true;
            }
            $params['hostname'] = substr($params['hostname'], $idx+3);
        }

        $params['withSSL'] = false;
        $params['withTLS'] = false;
        if (array_key_exists('security', $params)) {
            switch($params['security']) {
            case 'SSL':
                $params['withSSL'] = true;
                break;
            case 'TLS':
                $params['withTLS'] = true;
                break;
            default:
                throw new \InvalidArgumentException(
                    sprintf(
                        'Security mode %s not supported - only SSL or TLS are supported',
                        $params['security']
                    )
                );
            }
        } elseif ($enforceSSL) {
            $params['withSSL'] = true;
        }

        if (! array_key_exists('port', $params)) {
            if ($params['withSSL']) {
                $params['port'] = 636;
            } else {
                $params['port'] = 389;
            }
        }

        if (! array_key_exists('options', $params)) {
            $params['options'] = array();
        }

        $params['bind_anonymous'] = false;
        if ((! array_key_exists('bind_dn', $params)) || (strlen(trim($params['bind_dn'])) == 0)) {
            $params['bind_anonymous'] = true;
            $params['bind_dn']        = '';
            $params['bind_password']  = '';
        }
        if (! array_key_exists('bind_password', $params)) {
            $params['bind_password']  = '';
        }

        $this->configuration = $params;
    }
517449
protected function validateRequiredParameters(array $required, array $params)
    {
        foreach ($required as $param) {
            if (!isset($params[$param])) {
                throw new MissingArgumentException(sprintf('The "%s" parameter is required.', $param));
            }
        }
    }
178311
public function updateDefault(array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::PUT,
            ResourceMethodEnum::UPDATE_DEFAULT,
            $params,
            null
        );
    }
937023
public function addParameters(array $params)
    {
        if (!is_array($params)) {
            throw new \InvalidArgumentException('$params has to be an array');
        }
        $this->parameters = array_merge($this->parameters, $params);
    }
532733
final public function validateParameters(array $parameters)
    {
        $parameters = array_map(function ($rules) {
            if (is_bool($rules) and $rules === true) {
                return 'required';
            }

            return $rules;

        }, $parameters);

        $validator = Validator::make(Request::all(), $parameters);

        if ($validator->fails()) {
            throw new MissingParameterException(
                $validator->errors()->getMessages()
            );
        }

        return true;
    }
1184796
public function withParams(array $params): ParamHolderInterface
    {
        $param_holder = clone $this;
        $param_holder->params = array_merge($param_holder->params, $params);
        return $param_holder;
    }
588944
public function setParams(array $params = [])
    {
        if (empty($params) || count($params) < 4) {
            throw new \InvalidArgumentException(
            'Missing required params for Octopush message'
          );
        }

        foreach ($params as $key => $param) {
            if (!in_array($key, array_merge($this->requiredKeys, $this->optionalKeys))) {
                throw new \InvalidArgumentException(
                  'Missing required params for Octopush message'
                );
            }
        }

        foreach ($params as $key => $value) {
            $method = 'set' . $this->setMethod($key);
            $this->$method($value);
        }

        // set default params
        $this->params['sending_time'] = (new \DateTime())->getTimestamp();

        if (isset($this->params['sending_date'])) {
            $this->params['sms_mode'] = static::WITH_DELAY;
        }

        if (isset($this->params['request_keys'])) {
            $this->params['request_sha1'] = $this->encrypt($this->params);
        }

        if ($this->params['sms_type'] === 'FR') {
            $this->params['sms_text'] .= PHP_EOL . 'STOP au XXXXX';
        }

        return $this;
    }
204239
protected function formatParameters(array $params)
    {
        $formatted = [];

        foreach ($params as $name => $value) {
            if (!in_array($name, ['member_count', 'room_limit', 'path', 'version_type'], true)) {
                continue;
            }

            if ('version_type' === $name && !in_array($value, ['develop', 'trial', 'release'], true)) {
                throw new InvalidArgumentException('Invalid value of attribute "version_type".');
            }

            $formatted[] = [
                'name' => $name,
                'value' => strval($value),
            ];
        }

        return $formatted;
    }
956413
private function setSaltFromParams(array $params)
    {
        $salt = $this->getMatchingData($params, '/^[\.\\A-Za-z0-9]{22}$/');
        $this->salt = (! empty($salt)) ? $salt : self::DEFAULT_SALT;
    }
1260680
public function removeParams(array $removeParams)
    {
        $parts = $this->split($this->url);

        parse_str($parts['query'], $params);
        $params = array_diff_key($params, array_flip($removeParams));
        $parts['query'] = http_build_query($params);

        return $this->join($parts);
    }
694960
public function validate(&$params)
    {
        if (!is_array($params)) {
            throw new InvalidArgumentException('Please use array params when call validate.');
        }
        $rules = $this->validators;

        if (count($params) < count($rules)) {
            if (!isset($this->defaultValues) || empty($this->defaultValues)) {
                throw new InvalidArgumentException('The params are less than validators.');
            }
            $defaultValues = $this->defaultValues;

            foreach ($defaultValues as $key => $value) {
                if (!isset($params[$key])) {
                    $params[$key] = $value;
                }

            }
        } elseif (count($params) > count($rules)) {
            throw new InvalidArgumentException('The params are more than validators.');
        }
        foreach ($rules as $key => $rule) {
            if (isset($params[$key])) {
                if (is_array($rule)) {
                    $isError = true;

                    foreach ($rule as $subRule) {
                        if (call_user_func([$subRule, 'validate'], $params[$key]) === true) {
                            $isError = false;
                            break;
                        }
                    }
                    if ($isError) {
                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
                    }
                } else {
                    if (call_user_func([$rule, 'validate'], $params[$key]) === false) {
                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
                    }
                }
            } else {
                throw new RuntimeException($this->method . ' method argument ' . $key . ' doesn\'t have default value.');
            }
        }
        return true;
    }
57694
protected function validateParams(array $params)
    {
        foreach ($params as $param) {
            if (!$this->hasRequestParameter($param)) {
                throw new common_exception_MissingParameter($param .' is missing from the request.', $this->getRequestURI());
            }

            if (empty($this->getRequestParameter($param))) {
                throw new common_exception_ValidationFailed($param, $param .' cannot be empty');
            }
        }
    }
305396
protected function prepareParams(array $params)
	{
		$prepared = [];
		
		foreach($params as $k => $v)
		{
			if(is_array($v))
			{
				foreach(array_values($v) as $i => $val)
				{
					$prepared[sprintf('%s%u', $k, $i)] = $val;
				}
			}
			else
			{
				$prepared[(string)$k] = $v;
			}
		}
		
		return $prepared;
	}
1270889
private function buildParams($params)
    {
        $keys = is_array($params) ? $params : func_get_args();

        $array = [];

        foreach ($keys as $key) {
            if (property_exists($this, $key))
                $array = array_merge($array, [$key => $this->$key]);
        }

        return $array;
    }
153760
public function setupParams($params = [])
    {
        if (is_array($params)) {
            $this->params = array_merge($this->params, $params);
        }
        return $this;
    }
91062
public function setStatus(array $params)
	{
		if (!isset($params['identifier'])) {
			throw new MissingArgumentException('identifier');
		}

		if (!isset($params['status'])) {
			throw new MissingArgumentException('status');
		}

		return $this->post('set_status', $params);
	}
1237513
private function cleanParams(array $params = [])
    {
        if (isset($params['project'])) {
            $apiProject = $this->client->project;
            $params['project_id'] = $apiProject->getIdByName($params['project']);
            unset($params['project']);
            if (isset($params['category'])) {
                $apiIssueCategory = $this->client->issue_category;
                $params['category_id'] = $apiIssueCategory->getIdByName($params['project_id'], $params['category']);
                unset($params['category']);
            }
        }
        if (isset($params['status'])) {
            $apiIssueStatus = $this->client->issue_status;
            $params['status_id'] = $apiIssueStatus->getIdByName($params['status']);
            unset($params['status']);
        }
        if (isset($params['tracker'])) {
            $apiTracker = $this->client->tracker;
            $params['tracker_id'] = $apiTracker->getIdByName($params['tracker']);
            unset($params['tracker']);
        }
        if (isset($params['assigned_to'])) {
            $apiUser = $this->client->user;
            $params['assigned_to_id'] = $apiUser->getIdByUsername($params['assigned_to']);
            unset($params['assigned_to']);
        }
        if (isset($params['author'])) {
            $apiUser = $this->client->user;
            $params['author_id'] = $apiUser->getIdByUsername($params['author']);
            unset($params['author']);
        }

        return $params;
    }