Validate Client object structure

@param string|object $client JSON string or PHP Object created using json_decode. This contains your client SQS configuration which list your application `input` and `output` queues.
168860
private function validate_client($client)
    {
        if (!isset($client->{"name"}))
            throw new \Exception("'client' has no 'name'!");
        if (!isset($client->{"queues"}))
            throw new \Exception("'client' has no 'queues'!");
        if (!isset($client->{"queues"}->{'input'}))
            throw new \Exception("'client' has no 'input' queue!");
        if (!isset($client->{"queues"}->{'output'}))
            throw new \Exception("'client' has no 'output' queue !");
    }
1108285
private function sanitizeRequestOrThrowExceptionIfInvalid($request)
    {
        $isObject = ($request instanceof \stdClass);
        if (!is_array($request) && !$isObject) {
            throw new InvalidRequestException(
                'Request builder is intended to be used with arrays or instances of \\stdClass'
            );
        }
        return $isObject ? json_decode(json_encode($request), true) : $request;
    }
1093949
private function validate()
    {
        if (isset($this->_values[self::OPTION_HOST]) && !is_string($this->_values[self::OPTION_HOST])) {
            throw new ClientException('host should be a string');
        }

        if (isset($this->_values[self::OPTION_PORT]) && !is_int($this->_values[self::OPTION_PORT])) {
            throw new ClientException('port should be an integer');
        }

        // can use either endpoint or host/port
        $optionHost     = $this->_values[self::OPTION_HOST];
        $optionEndpoint = $this->_values[self::OPTION_ENDPOINT];
        if (isset($optionHost, $optionEndpoint)) {
            throw new ClientException('must not specify both host and endpoint');
        } else {
            if (null !== $optionHost && null === $optionEndpoint) {
                // upgrade host/port to an endpoint
                $this->_values[self::OPTION_ENDPOINT] = 'tcp://' . $this->_values[self::OPTION_HOST] . ':' . $this->_values[self::OPTION_PORT];
            }
        }

        assert(isset($this->_values[self::OPTION_ENDPOINT]));
        // set up a new endpoint, this will also validate it
        $this->getEndpoint();
        if (Endpoint::getType($this->_values[self::OPTION_ENDPOINT]) === Endpoint::TYPE_UNIX) {
            // must set port to 0 for UNIX sockets
            $this->_values[self::OPTION_PORT] = 0;
        }

        if (isset($this->_values[self::OPTION_AUTH_TYPE]) && !in_array(
                $this->_values[self::OPTION_AUTH_TYPE],
                self::getSupportedAuthTypes(),
                true
            )
        ) {
            throw new ClientException('unsupported authorization method');
        }

        if (isset($this->_values[self::OPTION_CLIENT]) && !in_array(
                $this->_values[self::OPTION_CLIENT],
                self::getSupportedClientTypes(),
                true
            )
        ) {
            throw new ClientException(
                sprintf(
                    "unsupported client value '%s'",
                    $this->_values[self::OPTION_CLIENT]
                )
            );
        }

        UpdatePolicy::validate($this->_values[self::OPTION_UPDATE_POLICY]);
        UpdatePolicy::validate($this->_values[self::OPTION_REPLACE_POLICY]);
        UpdatePolicy::validate($this->_values[self::OPTION_DELETE_POLICY]);
    }
485144
private function validateSearchClients(array $clients)
    {
        foreach ($clients as $name => $config) {
            $this->validateTypeAndService($config, sprintf('as3_modlr.search_clients.%s', $name));
            switch ($config['type']) {
                case 'elastic':
                    $this->validateLibClassExists('Search\Elastic\Client', sprintf('as3_modlr.search_clients.%s.type', $name));
                    break;
                default:
                    break;
            }
        }
    }
400343
public function refresh(Client $client)
    {
        $clientId = $client->getId();
        $this->clients[$clientId] = $client;
        $this->removeClientForRequest($clientId, $client->getPreviousRequest());

        $requestId = $client->getRequest();
        if ($requestId  !== null) {
            if (!isset($this->requests[$requestId])) {
                $this->requests[$requestId] = array();
            }
            $this->requests[$requestId][$clientId] = $client;
            $this->clientRequest[$clientId] = $requestId;
        }

        return $this;
    }
867122
public static function append($client)
	{
		if (is_array($client))
		{
			$client = (object) $client;
		}

		if (!is_object($client))
		{
			return false;
		}

		$info = self::client();

		if (!isset($client->id))
		{
			$client->id = count($info);
		}

		self::$_clients[$client->id] = clone $client;

		return true;
	}
370151
private function isValidError($payload): bool
    {
        if (!is_array($payload)) {
            return false;
        }

        $headerValid = array_key_exists('jsonrpc', $payload) && $payload['jsonrpc'] === '2.0';
        $errorValid  = array_key_exists('error', $payload) && is_array($payload['error'])
                       && array_key_exists('code', $payload['error']) && is_int($payload['error']['code'])
                       && array_key_exists('message', $payload['error']) && is_string($payload['error']['message']);
        $idValid     = array_key_exists('id', $payload);

        return $headerValid && $errorValid && $idValid;
    }
1046824
public function validateRequest(RequestInterface $request, ResponseInterface $response)
    {
        if (!$clientData = $this->getClientCredentials($request, $response)) {
            return false;
        }

        if (!isset($clientData['client_id'])) {
            throw new LogicException('the clientData array must have "client_id" set');
        }

        if (!isset($clientData['client_secret']) || $clientData['client_secret'] == '') {
            if (!$this->config['allow_public_clients']) {
                $response->setError(400, 'invalid_client', 'client credentials are required');

                return false;
            }

            if (!$this->storage->isPublicClient($clientData['client_id'])) {
                $response->setError(400, 'invalid_client', 'This client is invalid or must authenticate using a client secret');

                return false;
            }
        } elseif ($this->storage->checkClientCredentials($clientData['client_id'], $clientData['client_secret']) === false) {
            $response->setError(400, 'invalid_client', 'The client credentials are invalid');

            return false;
        }

        $this->clientData = $clientData;

        return true;
    }
1189216
protected function validateObject($object)
    {
        $classSchema = $this->reflectionService->getClassSchema($object);
        $validator = $this->validatorResolver->getBaseValidatorConjunction($classSchema->getClassName());
        if ($validator === null) {
            return;
        }
        $validationResult = $validator->validate($object);
        if ($validationResult->hasErrors()) {
            $errorMessages = '';
            $allErrors = $validationResult->getFlattenedErrors();
            foreach ($allErrors as $path => $errors) {
                $errorMessages .= $path . ':' . PHP_EOL;
                foreach ($errors as $error) {
                    $errorMessages .= (string)$error . PHP_EOL;
                }
            }
            throw new ObjectValidationFailedException('An instance of "' . get_class($object) . '" failed to pass validation with ' . count($errors) . ' error(s): ' . PHP_EOL . $errorMessages, 1322585162);
        }
    }
212111
public function deleteClientAction(Client $client)
    {
        $oldid = $client->getId();
        $this->oauthManager->deleteClient($client);

        return new JsonResponse(['id' => $oldid]);
    }
1279005
public function authenticate(ClientContract $client): void
    {
        if ($this->cookie !== '' || $this->isAuthenticating) {
            return;
        }

        $this->isAuthenticating = true;
        $response = $client->request('POST', '/user/login', [
            'login' => $this->username,
            'password' => $this->password,
        ]);
        $this->isAuthenticating = false;

        if ($response->isStatusCode(200)) {
            $this->cookie = $response->cookie();
        }
    }
689903
protected function createClientCredentialsClient(ClientRepository $clients)
    {
        $name = $this->option('name') ?: $this->ask(
            'What should we name the client?',
            config('app.name').' ClientCredentials Grant Client'
        );

        $client = $clients->create(
            null, $name, ''
        );

        $this->info('New client created successfully.');

        $this->outputClientDetails($client);
    }
1002783
private static function isValidObject($object): bool {
        if (null === $object) {
            return false;
        }
        if (!\is_object($object)) {
            return false;
        }
        return true;
    }
461126
public static function loadDefinitions(Client $client)
    {
        $serviceDescriptions = ServiceDescription::factory(__DIR__.'/Resources/config/meetup.json');

        foreach ($serviceDescriptions->getOperations() as $operation) {
            /* @var $operation Operation */
            $operation->setClass('DMS\Service\Meetup\Command\MeetupCommand');
        }

        $client->setDescription($serviceDescriptions);
    }
692637
private function isValidResult($payload): bool
    {
        if (!is_array($payload)) {
            return false;
        }

        $headerValid = array_key_exists('jsonrpc', $payload) && $payload['jsonrpc'] === '2.0';
        $resultValid = array_key_exists('result', $payload);
        $idValid     = array_key_exists('id', $payload);

        return $headerValid && $resultValid && $idValid;
    }
402192
public function isValid($json=null) {
			if (empty($json) || ctype_space($json)) return false;
			json_decode($json);
			return (json_last_error() === JSON_ERROR_NONE);
		}
871054
public function refreshContentTypeCache(Client $client): void
    {
        $spacePath = $this->getSpaceCachePath($client);
        $contentTypes = $client->getContentTypes();
        foreach ($contentTypes as $contentType) {
            $this->fileSystem->dumpFile($spacePath . '/ct-' . $contentType->getId() . '.json', (string) json_encode($contentType));
        }
    }