/** * IssuerDiscoveryEndpoint constructor. * * @param \OAuth2\UserAccount\UserAccountManagerInterface $user_account_manager * @param \OAuth2\Exception\ExceptionManagerInterface $exception_manager * @param string $issuer The issuer of the resource * @param string $server The server URI of this discovery service */ public function __construct(UserAccountManagerInterface $user_account_manager, ExceptionManagerInterface $exception_manager, $issuer, $server) { Assertion::url($issuer, 'The issuer must be an URL.'); Assertion::url($server, 'The server must be an URL.'); $this->setUserAccountManager($user_account_manager); $this->setExceptionManager($exception_manager); $this->setIssuer($issuer); $this->computed_server = $this->getDomain($server); }
/** * Create a new immutable Body instance * * @param string $route * @param string $signature * @param array $data * @return void */ public function __construct($route, $signature, $data) { Assertion::url($route); Assertion::string($signature); Assertion::isArray($data); $this->route = $route; $this->signature = $signature; $this->data = $data; }
/** * Constructor. * * @param Identifier $identifier * @param \DateTimeImmutable $createdAt * @param string $url * @param string $visibility */ public function __construct(Identifier $identifier, \DateTimeImmutable $createdAt, $url, $visibility) { Assertion::choice($visibility, static::$visibilityEnum); Assertion::url($url); $this->identifier = $identifier; $this->createdAt = $createdAt; $this->url = $url; $this->visibility = $visibility; }
/** * Constructor. * * @param Identifier $identifier * @param string $name * @param boolean $isPrimary */ public function __construct(Identifier $identifier, $name, $iconUrl, $isPrimary) { \Assert\that($name)->string()->notEmpty(); Assertion::boolean($isPrimary); Assertion::url($iconUrl); $this->identifier = $identifier; $this->name = $name; $this->iconUrl = $iconUrl; $this->isPrimary = $isPrimary; }
/** * Constructor. * * @param string $clientId * @param string $clientSecret * @param string|null $basePath */ public function __construct($clientId, $clientSecret, $basePath = null) { \Assert\that($clientId)->string()->notEmpty(); \Assert\that($clientSecret)->string()->notEmpty(); if ($basePath !== null) { Assertion::url($basePath); $this->basePath = rtrim($basePath, '/'); } $this->clientId = $clientId; $this->clientSecret = $clientSecret; }
/** * Получить AccessToken из консоли * * @param EventInterface $e * * @return string|null * @throws \Zend\Console\Exception\RuntimeException * @throws \Zend\Console\Exception\InvalidArgumentException * @throws \Assert\AssertionFailedException */ public function getAccessToken(EventInterface $e) { if (!Console::isConsole()) { return null; } $authUrl = $e->getParam('authUrl', null); Assertion::url($authUrl); $console = Console::getInstance(); $console->writeLine(sprintf('Open the following link in your browser:')); $console->writeLine($authUrl); $console->writeLine(); $console->write('Enter verification code: '); return $console->readLine(); }
/** * @param array $configuration Array with configuration settings * @throws InvalidArgumentException */ public function __construct(array $configuration) { // Validate and set base url Assertion::notEmptyKey($configuration, 'apiBaseUrl', 'apiBaseUrl is required'); Assertion::url($configuration['apiBaseUrl'], 'apiBaseUrl has to be a valid url'); $this->apiBaseUrl = rtrim($configuration['apiBaseUrl'], '/'); // Validate username Assertion::notEmptyKey($configuration, 'username', 'username is required'); Assertion::string($configuration['username'], 'username has to be a string'); $this->username = trim($configuration['username']); // Validate api interface id Assertion::notEmptyKey($configuration, 'apiId', 'apiId is required'); Assertion::integer($configuration['apiId'], 'apiId has to be an integer'); $this->apiId = trim($configuration['apiId']); // Validate api key Assertion::notEmptyKey($configuration, 'apiKey', 'apiKey is required'); Assertion::string($configuration['apiKey'], 'apiKey has to be a string'); $this->apiKey = trim($configuration['apiKey']); // Check if clientConfiguration is set and valid if (isset($configuration['clientConfiguration'])) { Assertion::isArray($configuration['clientConfiguration'], 'clientConfiguration has to be an array'); $this->clientConfiguration = $configuration['clientConfiguration']; } }
/** * @dataProvider dataValidUrl */ public function testValidUrl($url) { Assertion::url($url); }
/** * @param string $url * * @throws \OAuth2\Exception\BadRequestExceptionInterface * * @return string */ private function checkSectorIdentifierUri($url) { $allowed_protocols = ['https']; if (true === $this->allow_http_connections) { $allowed_protocols[] = 'http'; } Assertion::inArray(mb_substr($url, 0, mb_strpos($url, '://', 0, '8bit'), '8bit'), $allowed_protocols, sprintf('The provided sector identifier URI is not valid: scheme must be one of the following: %s.', json_encode($allowed_protocols))); $client = new Client(['verify' => !$this->allow_unsecured_connections]); $response = $client->get($url); Assertion::eq(200, $response->getStatusCode()); $body = $response->getBody()->getContents(); $data = json_decode($body, true); Assertion::isArray($data, 'The provided sector identifier URI is not valid: bad response.'); Assertion::notEmpty($data, 'The provided sector identifier URI is not valid: it must contain at least one URI.'); foreach ($data as $sector_url) { Assertion::url($sector_url, 'The provided sector identifier URI is not valid: it must contain only URIs.'); Assertion::inArray(mb_substr($sector_url, 0, mb_strpos($sector_url, '://', 0, '8bit'), '8bit'), $allowed_protocols, sprintf('An URL provided in the sector identifier URI is not valid: scheme must be one of the following: %s.', json_encode($allowed_protocols))); } }
public function __construct($url) { Assertion::url($url); $this->url = $url; }
public function __construct($url) { Assertion::url($url); parent::__construct($url); }
/** * @param string $location * * @throws \InvalidArgumentException */ public function __construct($location) { Assertion::url($location); $this->location = $location; }
/** * Устанавливает урл гитлаба * * @param string $url * * @return $this * @throws \Assert\AssertionFailedException */ public function setUrl($url) { Assertion::url($url); $this->url = $url; return $this; }
private function __construct($url) { Ensure::url($url); $this->url = $url; }
private function getUriVerificationClosure() { return function ($k, $v) { Assertion::url($v, sprintf('The parameter with key "%s" is not a valid URL.', $k)); }; }