本文整理汇总了PHP中Assert\Assertion::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::url方法的具体用法?PHP Assertion::url怎么用?PHP Assertion::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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);
}
示例2: __construct
/**
* 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;
}
示例3: __construct
/**
* 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;
}
示例4: __construct
/**
* 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;
}
示例5: __construct
/**
* 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;
}
示例6: getAccessToken
/**
* Получить 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();
}
示例7: __construct
/**
* @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'];
}
}
示例8: testValidUrl
/**
* @dataProvider dataValidUrl
*/
public function testValidUrl($url)
{
Assertion::url($url);
}
示例9: checkSectorIdentifierUri
/**
* @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)));
}
}
示例10: __construct
public function __construct($url)
{
Assertion::url($url);
$this->url = $url;
}
示例11: __construct
public function __construct($url)
{
Assertion::url($url);
parent::__construct($url);
}
示例12: __construct
/**
* @param string $location
*
* @throws \InvalidArgumentException
*/
public function __construct($location)
{
Assertion::url($location);
$this->location = $location;
}
示例13: setUrl
/**
* Устанавливает урл гитлаба
*
* @param string $url
*
* @return $this
* @throws \Assert\AssertionFailedException
*/
public function setUrl($url)
{
Assertion::url($url);
$this->url = $url;
return $this;
}
示例14: __construct
private function __construct($url)
{
Ensure::url($url);
$this->url = $url;
}
示例15: getUriVerificationClosure
private function getUriVerificationClosure()
{
return function ($k, $v) {
Assertion::url($v, sprintf('The parameter with key "%s" is not a valid URL.', $k));
};
}