本文整理汇总了PHP中Assert\Assertion::boolean方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::boolean方法的具体用法?PHP Assertion::boolean怎么用?PHP Assertion::boolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::boolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* RedirectUriParameterChecker constructor.
*
* @param bool $secured_redirect_uri_enforced
* @param bool $redirect_uri_storage_enforced
*/
public function __construct($secured_redirect_uri_enforced, $redirect_uri_storage_enforced)
{
Assertion::boolean($secured_redirect_uri_enforced);
Assertion::boolean($redirect_uri_storage_enforced);
$this->secured_redirect_uri_enforced = $secured_redirect_uri_enforced;
$this->redirect_uri_storage_enforced = $redirect_uri_storage_enforced;
}
示例2: __construct
/**
* @param array $config
* @param bool $singletonDefault
*
* @throws InvalidArgumentException
*/
public function __construct(array $config, $singletonDefault = false)
{
Assertion::boolean($singletonDefault);
foreach ($config as $key => $serviceConfig) {
$this->config[] = new ServiceDefinition($key, $serviceConfig, $singletonDefault);
}
}
示例3: __construct
public function __construct($name, $set)
{
Assertion::string($name);
Assertion::boolean($set);
$this->name = $name;
$this->set = $set;
}
示例4: __construct
public function __construct($name, $type, $analyzable = false)
{
Assertion::string($name);
Assertion::string($type);
Assertion::boolean($analyzable);
$this->name = $name;
$this->type = $type;
$this->analyzable = $analyzable;
}
示例5: __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;
}
示例6: __construct
private function __construct(PersonalInformation $personalInformation, $indication, $arrived, PatientId $id)
{
Assertion::string($indication);
Assertion::notEmpty($indication);
$this->indication = $indication;
Assertion::boolean($arrived);
$this->arrived = $arrived;
$this->personalInformation = $personalInformation;
$this->id = $id;
}
示例7: __construct
/**
* @param string $name
* @param array $config
* @param bool $singletonDefault
*
* @throws InvalidArgumentException
* @throws InvalidConfigException
*/
public function __construct($name, array $config, $singletonDefault = false)
{
Assertion::string($name);
Assertion::boolean($singletonDefault);
$this->name = $name;
$this->class = $this->className($name, $config);
$this->isSingleton = isset($config['singleton']) ? $config['singleton'] : $singletonDefault;
$this->isFactory = isset($config['factory']);
$this->isAlias = isset($config['service']);
$this->arguments = isset($config['arguments']) ? $config['arguments'] : [];
$this->methods = isset($config['methods']) ? $config['methods'] : [];
}
示例8: __construct
public function __construct(Key $key, $lb, $li = false, $hb = null, $hi = false)
{
Assertion::nullOrScalar($lb);
Assertion::boolean($li);
Assertion::nullOrScalar($hb);
Assertion::boolean($hi);
$this->key = $key;
$this->lower_bound = $lb;
$this->lower_inclusive = $li;
$this->higher_bound = $hb;
$this->higher_inclusive = $hi;
}
示例9: add
/**
* Adds a replacement key value pair.
* The value can be a string or an callable which must return a string.
*
* @param string $key The key
* @param string|callable $value The value
* @param boolean $environment Set as environment var
*
* @return $this
* @throws \InvalidArgumentException Value must be a string or callable
*/
public function add($key, $value, $environment = false)
{
\Assert\that($key)->string()->notEmpty()->regex('/^[A-Z0-9\\_]*$/', 'Replacement key does not match expected format.');
Assertion::boolean($environment);
if (!is_string($value) && !is_callable($value)) {
throw new \InvalidArgumentException(sprintf("Value must be a string or callable. Given: '%s'", gettype($value)));
}
$this->values[$this->delimiter . $key . $this->delimiter] = $value;
if ($environment) {
$environmentVar = sprintf('%s=%s', $key, $value);
$this->logger->debug(sprintf('Setting environment var: %s', $environmentVar));
putenv($environmentVar);
}
return $this;
}
示例10: __construct
/**
* @param string $label
* @param string $nativeType
* @param bool $hasIdentifier
* @param null|string $identifierName
*/
public function __construct($label, $nativeType, $hasIdentifier, $identifierName = null)
{
Assertion::notEmpty($label);
Assertion::string($label);
Assertion::inArray($nativeType, NativeType::all());
Assertion::boolean($hasIdentifier);
if (!is_null($identifierName)) {
Assertion::notEmpty($identifierName);
Assertion::string($identifierName);
}
$this->label = $label;
$this->nativeType = $nativeType;
$this->hasIdentifier = $hasIdentifier;
$this->identifierName = $identifierName;
}
示例11: update
public function update($id, $name, $price, $active, $thumb, $content)
{
Assertion::string($name);
Assertion::boolean($active);
$product = $this->products->productOfId($id);
$product->name = $name;
$product->slug = Str::slug($name);
$product->price = $price;
$product->active = $active;
if ($thumb) {
$product->thumb = $thumb;
}
$product->content = $content;
$this->products->update($product);
return $product;
}
示例12: __construct
/**
* DownloadedJWKSet constructor.
*
* @param string $url
* @param \Psr\Cache\CacheItemPoolInterface|null $cache
* @param int $ttl
* @param bool $allow_unsecured_connection
* @param bool $allow_http_connection
*/
public function __construct($url, CacheItemPoolInterface $cache = null, $ttl = 86400, $allow_unsecured_connection = false, $allow_http_connection = false)
{
Assertion::boolean($allow_unsecured_connection);
Assertion::boolean($allow_http_connection);
Assertion::integer($ttl);
Assertion::min($ttl, 0);
Assertion::false(false === filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED), 'Invalid URL.');
$allowed_protocols = ['https'];
if (true === $allow_http_connection) {
$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)));
$this->url = $url;
$this->cache = $cache;
$this->ttl = $ttl;
$this->allow_unsecured_connection = $allow_unsecured_connection;
}
示例13: __construct
/**
* Constructor.
*
* @param bool $verified
* @param \DateTimeImmutable|null $createdAt
* @param Photo\Photo $bestPhoto
* @param float|null $rating
* @param string|null $url
* @param int|null $hereNow
* @param string[] $tags
* @param int|null $likes
* @param \DateTimeZone|null $timeZone
*/
public function __construct($verified, \DateTimeImmutable $createdAt = null, Photo\Photo $bestPhoto = null, $rating = null, $url = null, $hereNow = null, $tags = [], $likes = null, \DateTimeZone $timeZone = null)
{
Assertion::boolean($verified);
Assertion::isArray($tags);
Assertion::nullOrInteger($likes);
Assertion::nullOrFloat($rating);
Assertion::nullOrString($url);
Assertion::nullOrInteger($hereNow);
$this->verified = $verified;
$this->rating = $rating;
$this->hereNow = $hereNow;
$this->url = $url;
$this->createdAt = $createdAt;
$this->timeZone = $timeZone;
$this->bestPhoto = $bestPhoto;
$this->tags = $tags;
$this->likes = $likes;
}
示例14: __construct
public function __construct($name, $type, array $options = [])
{
$this->name = (string) $name;
$this->type = $type;
$this->is_searchable = \igorw\get_in($options, ['searchable'], true);
$this->is_private = \igorw\get_in($options, ['private'], false);
$this->facet = \igorw\get_in($options, ['facet']);
$this->thesaurus_roots = \igorw\get_in($options, ['thesaurus_roots'], null);
$this->used_by_collections = \igorw\get_in($options, ['used_by_collections'], []);
Assertion::boolean($this->is_searchable);
Assertion::boolean($this->is_private);
if ($this->facet !== self::FACET_DISABLED) {
Assertion::integer($this->facet);
}
if ($this->thesaurus_roots !== null) {
Assertion::allIsInstanceOf($this->thesaurus_roots, Concept::class);
}
Assertion::allScalar($this->used_by_collections);
}
示例15: deploy
/**
* Invokes a deployment.
*
* @param Project $project The project
* @param string $environment The environment
* @param bool $dryRun IF deployment is a dry run
*
* @return DeploymentPayload
*/
public function deploy(Project $project, $environment, $dryRun)
{
\Assert\that($environment)->string()->notEmpty();
Assertion::boolean($dryRun);
$this->logger->debug(sprintf("Deploying '%s' to '%s'", $project->getName(), $environment));
$environment = $project->getEnvironment($environment);
$runner = $this->mappingConverter->convert($environment->getMapping());
$projectDirectory = $this->projectDirectoryHelper->create($project);
$this->interpolator->add('PROJECT', $environment->getName());
$this->interpolator->add('ENVIRONMENT', $environment->getName());
$this->interpolator->add('PROJECT_DIRECTORY', $projectDirectory);
$payload = new DeploymentPayload();
$payload->setProject($project);
$payload->setEnvironment($environment);
$payload->setProjectDirectory($projectDirectory);
$payload->setDryRun($dryRun);
$payload = $runner->run($payload);
$this->projectDirectoryHelper->cleanup($project);
return $payload;
}