Gets the using statement for Auth.

@param array $fields
@param bool $withAuth

@return string
541677
protected function getRequiredUseClasses(array $fields, $withAuth)
    {
        $commands = [];
        if ($withAuth) {
            $commands[] = $this->getUseClassCommand('Auth');
        }

        foreach ($fields as $field) {
            // Extract the name spaces fromt he custom rules
            $customRules = $this->extractCustomValidationRules($field->getValidationRule());
            $namespaces = $this->extractCustomValidationNamespaces($customRules);
            foreach ($namespaces as $namespace) {
                $commands[] = $this->getUseClassCommand($namespace);
            }
        }

        usort($commands, function ($a, $b) {
            return strlen($a) - strlen($b);
        });

        return implode(PHP_EOL, array_unique($commands));
    }
1060048
public static function authQueryString($authKey, $accessToken, $request = null)
    {
        return HashHelper::hash($request ? $request->getParam($authKey) : Lb::app()->getParam($authKey)) == $accessToken;
    }
653369
public function with($withs)
    {
        if ( ! is_array($withs)) {
            $withs = func_get_args();
        }

        $this->withs = $withs;

        return $this;
    }
52068
protected function getMetaboxPlaceholders(array $fields)
    {
        $placeholders = [];

        foreach ($fields as $field) {
            /** @var FieldTypeInterface $field */
            $placeholders[$field->getName()] = $field->getOption('placeholder');
        }

        return $placeholders;
    }
1018479
public function getValueWithMultipleWhere($wheres = '', $field = 'id', $fieldOutput = '')
    {
        if (is_array($wheres) && count($wheres) > 0) {
            foreach ($wheres as $key => $value) {
                if (is_array($value['value'])) {
                    $this->db->where($value['field'], $value['value'], self::OPERATOR_IS_IN);
                } else {
                    $this->db->where($value['field'], $value['value'], $value['operator']);
                }
            }
        } else {
            $this->db->where($field, $wheres, self::OPERATOR_EQUAL_TO);
        }
        $result = $this->db->getOne($this->table, $fieldOutput);
        $this->debug->debug(__FUNCTION__, 'GET Result => ' . json_encode($result));
        if (isset($result->$fieldOutput)) {
            return $result->$fieldOutput;
        } else {
            return NULL;
        }
    }
1116693
public function get($webhookId, array $fields = array())
    {
        $params = array();
        if (!empty($fields)) {
            $params['fields'] = implode(',', $fields);
        }
        $response = $this->request('/admin/webhooks/'.$webhookId.'.json', 'GET', $params);
        return $this->createObject(Webhook::class, $response['webhook']);
    }
14649
public function raw($method, $path, $options, $withAuthorization = true)
    {
        // Find what traits this class is using.
        $class = get_called_class();
        $traits = Introspector::getAllClassTraits($class);

        if (empty($options['headers'])) {
            // Guzzle doesn't merge default headers with $options array
            $options['headers'] = $this->defaultHeaders ?: [];
        }

        // If these traits have a "hook" (uh oh!), run that before making a request.
        foreach ($traits as $trait) {
            $function = 'run'.Introspector::baseName($trait).'Tasks';
            if (method_exists($class, $method)) {
                $this->{$function}($method, $path, $options, $withAuthorization);
            }
        }

        return $this->client->request($method, $path, $options);
    }
1099996
public function getValueWithMultipleWhere($wheres = '', $field = 'id', $fieldOutput = '')
    {
        if (!is_array($fieldOutput)) {
            $fieldOutput = [$fieldOutput];
        }
        $db = $this->db->select($fieldOutput)->from($this->table);
        if (is_array($wheres) && count($wheres) > 0) {
            foreach ($wheres as $key => $value) {
                if (is_array($value['value'])) {
                    $db->whereIn($value['field'], $value['value']);
                } else {
                    $db->where($value['field'], $value['operator'], $value['value']);
                }
            }
        } else {
            $db->where($field, self::OPERATOR_EQUAL_TO, $wheres);
        }
        $result = $db->execute()->fetch();

        $this->debug->debug(__FUNCTION__, 'GET Result => ' . json_encode($result));
        if (isset($result->$fieldOutput)) {
            return $result->$fieldOutput;
        } else {
            return NULL;
        }
    }
267496
public function request($field = false)
    {
        $request = array_merge($this->request->request->all(), $this->request->query->all());
        $req = ($this->requestArray == false) ? $request : $this->requestArray;
        if ($this->attributeKey && is_array($req['akID'])) {
            $p = $req['akID'][$this->attributeKey->getAttributeKeyID()];
            if ($field) {
                return $p[$field];
            }

            return $p;
        }

        return parent::request($field);
    }
537724
public static function current($addAuth = false)
    {
        $current = (string)self::root($addAuth) . (string)self::path();
        return $current ?: null;
    }
1291831
public function getClientCredentialsToken(array $scopes = null):AccessToken{
		$params = [
			'client_id'     => $this->options->key,
			'client_secret' => $this->options->secret,
			'grant_type'    => 'client_credentials',
		];

		if($scopes !== null){
			$params['scope'] = implode($this->scopesDelimiter, $scopes);
		}

		$request = $this->requestFactory
			->createRequest('POST', $this->clientCredentialsTokenURL ?? $this->accessTokenURL)
			->withHeader('Content-Type', 'application/x-www-form-urlencoded')
			->withBody($this->streamFactory->createStream(http_build_query($params, '', '&', PHP_QUERY_RFC1738)))
		;

		foreach($this->authHeaders as $header => $value){
			$request = $request->withAddedHeader($header, $value);
		}

		$token = $this->parseTokenResponse($this->http->sendRequest($request));

		$this->storage->storeAccessToken($this->serviceName, $token);

		return $token;
	}
550342
public function newAuth($parameters = array(), $authMethod = 'OAuth')
    {
        $class      = 'Mautic\\Auth\\'.$authMethod;
        $authObject = new $class();

        $reflection = new \ReflectionMethod($class, 'setup');
        $pass       = array();

        foreach ($reflection->getParameters() as $param) {
            if (isset($parameters[$param->getName()])) {
                $pass[] = $parameters[$param->getName()];
            } else {
                $pass[] = null;
            }
        }

        $reflection->invokeArgs($authObject, $pass);

        return $authObject;
    }
286271
protected function resolveAuth(array $parameters, array $headers)
    {
        isset($parameters['PHP_AUTH_USER']) ? $this->resolvePHPAuth($parameters, $headers) : $this->resolveHTTPAuth($parameters, $headers);

        if (isset($headers['PHP_AUTH_USER'])) {
            $headers['AUTHORIZATION'] = 'basic ' . base64_encode($headers['PHP_AUTH_USER'] . ':' . $headers['PHP_AUTH_PW']);
        }

        return $headers;
    }
745307
public function getAccountSettings(array $parameters = array(), $multipart = false, $appOnlyAuth = false)
    {
        return $this->get('account/settings', $parameters, $multipart, $appOnlyAuth);
    }
1105269
public function resolveAuth( $auth )
	{
		$config = Config::get( 'auth.auths.' . $auth );
		$uses = $config['uses'];

		switch ( $uses )
		{
			case 'database':
			{
				$auth = new DatabaseAuth( $config['table'] );
				break;
			}
			case 'eloquent':
			{
				$auth = new EloquentAuth( $config['usrModel'], $config['grpModel'] );
				break;
			}
			default:
			{
				$auth = UniversalBuilder::resolve( $uses );

				if ( is_null( $auth ) )
					throw new AccountException( "We could not resolve the auth [" . $uses . "]" );

				if ( !is_subclass_of( $auth, AccountAuth::class ) )
					throw new \InvalidArgumentException( "The auth [" . $uses . "] must extend the [" . AccountAuth::class . "] class" );
			}
		}

		return $auth;
	}
942680
public function fields( $fields )
	{
		if ( !is_array( $fields ) && !is_null( $fields ) )
		{
			$fields = array( $fields );
		}
		
		// do nothing if we get nothing
		if ( empty( $fields ) || $fields == array( '*' ) )
		{
			$this->fields = array(); return $this;
		}
		
		$this->fields = $fields;

		// return self so we can continue running the next function
		return $this;
	}
1106357
private static function resolveAttributes(array $attributes, string $id, bool $withMethod): array
    {
        $default = ['id' => $id, 'aliases' => []];
        if ($withMethod) {
            $default['method'] = '__invoke';
        }
        $attributes = \array_replace($default, $attributes);

        return $attributes;
    }