/** * 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; }
/** * @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); } }
public function __construct($name, $set) { Assertion::string($name); Assertion::boolean($set); $this->name = $name; $this->set = $set; }
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; }
/** * 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; }
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; }
/** * @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'] : []; }
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; }
/** * 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; }
/** * @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; }
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; }
/** * 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; }
/** * 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; }
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); }
/** * 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; }
public function __construct($filters, $offset, $limit, $sortField, $sortOrder, $isPaginated) { Assertion::isArray($filters, "Invalid filters"); Assertion::integerish($limit, "Invalid limit"); Assertion::integerish($offset, "Invalid offset"); Assertion::nullOrString($sortField, "Invalid sort field"); Assertion::choice($sortOrder, [null, self::ORDER_ASC, self::ORDER_DESC], "Invalid sort order"); Assertion::boolean($isPaginated, "Invalid value for isPaginated"); if ($limit < 0) { throw new \InvalidArgumentException("Invalid limit"); } if ($offset < 0) { throw new \InvalidArgumentException("Invalid offset"); } $this->filters = $filters; $this->offset = (int) $offset; $this->limit = (int) $limit; $this->sortField = $sortField; $this->sortOrder = $sortOrder; $this->isPaginated = (bool) $isPaginated; }
/** * Sends a message through the gateway. * * @param Message $message Message * @param bool $debug If debug mode should be enabled * * @return Response */ public function send(Message $message, $debug = false) { Assertion::boolean($debug); $params = $this->createParamsInstance(); $params->originator = $message->getFrom(); $params->destinations = $message->getTo(); $params->body = $message->getMessageText(); $params->validity = 48; $params->characterSetID = 2; $params->replyMethodID = 4; $this->setOptions($params, $message); if ($debug) { $method = 'TestSendSMS'; } else { $method = 'SendSMS'; } $result = $this->call($method, $params); $meta = $this->extractResponseMetaData($result); $response = new Response(time(), $meta['code'] === 1, $meta['code'], $meta['message']); return $response; }
/** * @param bool $issuer_included_as_parameter */ public function setIssuerIncludedAsParameter($issuer_included_as_parameter) { Assertion::boolean($issuer_included_as_parameter, 'A boolean is expected.'); $this->issuer_included_as_parameter = $issuer_included_as_parameter; }
/** * @param array $processingTypes * @param bool $supportAll */ private function __construct(array $processingTypes, $supportAll) { Assertion::allIsInstanceOf($processingTypes, Prototype::class); Assertion::boolean($supportAll); $this->supportedProcessingTypes = $processingTypes; $this->supportAllTypes = $supportAll; }
public function testInvalidBoolean() { $this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_BOOLEAN); Assertion::boolean(1); }
/** * @param bool $encryption_required * @param \Jose\Object\JWKSetInterface $key_encryption_key_set */ public function enableEncryptedAssertions($encryption_required, JWKSetInterface $key_encryption_key_set) { Assertion::boolean($encryption_required); $this->encryption_required = $encryption_required; $this->key_encryption_key_set = $key_encryption_key_set; }
/** * {@inheritdoc} */ public function enableEncryptedRequestObjectSupport(JWKSetInterface $key_encryption_key_set, $require_encryption) { Assertion::boolean($require_encryption); Assertion::true($this->isRequestObjectSupportEnabled(), 'Request object support must be enabled first.'); Assertion::greaterThan($key_encryption_key_set->countKeys(), 0, 'The encryption key set must have at least one key.'); $this->require_encryption = $require_encryption; $this->key_encryption_key_set = $key_encryption_key_set; }
/** * {@inheritdoc} */ public function load($assertion, Object\JWKSetInterface $encryption_key_set = null, $is_encryption_required = false) { Assertion::string($assertion); Assertion::boolean($is_encryption_required); $jwt = $this->loader->load($assertion); if ($jwt instanceof Object\JWEInterface) { Assertion::notNull($encryption_key_set, 'Encryption key set is not available.'); Assertion::true($this->isDecryptionSupportEnabled(), 'Encryption support is not enabled.'); Assertion::inArray($jwt->getSharedProtectedHeader('alg'), $this->getSupportedKeyEncryptionAlgorithms(), sprintf('The key encryption algorithm "%s" is not allowed.', $jwt->getSharedProtectedHeader('alg'))); Assertion::inArray($jwt->getSharedProtectedHeader('enc'), $this->getSupportedContentEncryptionAlgorithms(), sprintf('The content encryption algorithm "%s" is not allowed or not supported.', $jwt->getSharedProtectedHeader('enc'))); $jwt = $this->decryptAssertion($jwt, $encryption_key_set); } elseif (true === $is_encryption_required) { throw new \InvalidArgumentException('The assertion must be encrypted.'); } return $jwt; }
private function __construct(Coords $coords, $shot = false) { Assertion::boolean($shot); $this->coords = $coords; $this->shot = $shot; }
public function toFileMakerValue($value) { Assertion::boolean($value); return Decimal::fromInteger($value ? 1 : 0); }
/** * Sets the internal state * * @param string $internal */ public function setInternal($internal) { Assertion::boolean($internal); $this->internal = $internal; }
/** * @param boolean $updateToken */ protected function setUpdateToken($updateToken) { Assertion::boolean($updateToken); $this->updateToken = $updateToken; }
/** * Validate boolean: * true or false * @param boolean $publish */ public static function publish($publish) { Assert::boolean($publish); }
public function setAppname($name, $license = '', $xmit = false) { Assertion::string($name); Assertion::notBlank($name); Assertion::string($license); Assertion::boolean($xmit); return $this->handle('newrelic_set_appname', [$name, $license, $xmit]); }
/** * ResponseModeParameterChecker constructor. * * @param bool $response_mode_parameter_in_authorization_request_allowed */ public function __construct($response_mode_parameter_in_authorization_request_allowed) { Assertion::boolean($response_mode_parameter_in_authorization_request_allowed); $this->response_mode_parameter_in_authorization_request_allowed = $response_mode_parameter_in_authorization_request_allowed; }