本文整理汇总了PHP中Assert\Assertion::min方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::min方法的具体用法?PHP Assertion::min怎么用?PHP Assertion::min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::min方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createServiceWithName
/**
* Create service with name
*
* @param ServiceLocatorInterface $serviceLocator
* @param string $name
* @param string $requestedName
* @throws \LogicException
* @return mixed
*/
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
/** @var $env Environment */
$env = $serviceLocator->get(Definition::SERVICE_ENVIRONMENT);
$nameParts = explode('.', $requestedName);
Assertion::min(count($nameParts), 3, sprintf("Given service bus alias %s is invalid. Format should be processing.(command|event)_bus.[target]", $requestedName));
$busType = $nameParts[1];
unset($nameParts[0]);
unset($nameParts[1]);
$address = implode('.', $nameParts);
$busConfig = $this->getChannelConfigFor($env, $address);
$target = $this->getTargetFromAddress($address);
$bus = $busType === "command_bus" ? new CommandBus() : new EventBus();
$bus->utilize($this->getForwardToMessageDispatcher());
$bus->utilize($this->getToMessageTranslator());
$bus->utilize($this->getHandleWorkflowMessageStrategy());
$bus->utilize($this->getInvokeProcessorStrategy());
$bus->utilize(new ServiceLocatorProxy(Zf2ServiceManagerProxy::proxy($serviceLocator)));
$messageHandler = $busConfig->stringValue('message_dispatcher', $target);
if (!empty($messageHandler)) {
$bus->utilize(new SingleTargetMessageRouter($messageHandler));
} else {
throw new \LogicException("Missing a message handler for the bus " . $requestedName);
}
foreach ($busConfig->arrayValue('utils') as $busUtil) {
if (is_string($busUtil)) {
$busUtil = $serviceLocator->get($busUtil);
}
$bus->utilize($busUtil);
}
return $bus;
}
示例2: withData
/**
* @param string $aggregateType
* @param string $aggregateId
* @param int $version
* @return TakeSnapshot
*/
public static function withData($aggregateType, $aggregateId, $version)
{
Assertion::string($aggregateType);
Assertion::string($aggregateId);
Assertion::min($version, 1);
return new self(['aggregate_type' => $aggregateType, 'aggregate_id' => $aggregateId, 'version' => $version]);
}
示例3: __construct
/**
* @param CommandBus $commandBus
* @param int $versionStep
* @param array $eventNames
*/
public function __construct(CommandBus $commandBus, $versionStep, array $eventNames = [])
{
Assertion::min($versionStep, 1);
$this->commandBus = $commandBus;
$this->versionStep = $versionStep;
$this->eventNames = $eventNames;
$this->hasEventNames = !empty($eventNames);
}
示例4: __construct
/**
* Constructor
*
* @param AMQPQueue $queue
* @param int $waitMicros
* @param string|null $appId
*/
public function __construct(AMQPQueue $queue, $waitMicros = 1000, $appId = null)
{
Assertion::min($waitMicros, 1);
$this->queue = $queue;
$this->waitMicros = $waitMicros;
if (null !== $appId) {
Assertion::minLength($appId, 1);
$this->appId = $appId;
}
}
示例5: __construct
public function __construct($value)
{
parent::__construct($value);
try {
Assertion::min($value, 1);
$this->value = (int) $value;
} catch (AssertionInvalidArgumentException $exception) {
throw new InvalidArgumentException($value);
}
}
示例6: __construct
public function __construct(array $parameters, $offset, $limit)
{
Assertion::integer($offset);
Assertion::min($offset, 0);
Assertion::integer($limit);
Assertion::min($limit, 1);
$this->parameters = $parameters;
$this->offset = $offset;
$this->limit = $limit;
}
示例7: __construct
/**
* Constructor
*
* @param Queue $queue
* @param Exchange[] $exchanges
* @param int $waitMillis
* @param string $appId
*/
public function __construct(Queue $queue, array $exchanges, int $waitMillis = 100, string $appId = '')
{
Assertion::min($waitMillis, 1);
Assertion::notEmpty($exchanges, 'No exchanges given');
Assertion::allIsInstanceOf($exchanges, Exchange::class);
$this->queue = $queue;
$this->exchanges = $exchanges;
$this->waitMillis = $waitMillis;
$this->appId = $appId;
}
示例8: __construct
/**
* @param AggregateType $aggregateType
* @param string $aggregateId
* @param object $aggregateRoot
* @param int $lastVersion
* @param DateTimeImmutable $createdAt
*/
public function __construct(AggregateType $aggregateType, $aggregateId, $aggregateRoot, $lastVersion, DateTimeImmutable $createdAt)
{
Assertion::minLength($aggregateId, 1);
Assertion::isObject($aggregateRoot);
Assertion::min($lastVersion, 1);
$this->aggregateType = $aggregateType;
$this->aggregateId = $aggregateId;
$this->aggregateRoot = $aggregateRoot;
$this->lastVersion = $lastVersion;
$this->createdAt = $createdAt;
}
示例9: createFolders
/**
* Creates dummy folders, like the project directory helper would do.
*
* @param int $amount Amount of folders to create
*
* @return null
*/
private function createFolders($amount)
{
Assertion::integer($amount);
Assertion::min($amount, 1);
$fs = new Filesystem();
$date = new \DateTime();
$date->modify(sprintf('-%s days', $amount));
for ($i = 0; $i < $amount; $i++) {
$date->modify('+1 day');
$fs->mkdir(sprintf('%s/demo-project/%s', $this->getWorkspace(), $date->format('YmdHis')));
}
}
示例10: initialize
/**
* @param string $template
* @param string $title
* @param int $requiredCols
* @param null|array|\Traversable $variables
* @param null $newGroup
* @return DashboardWidget
*/
public static function initialize($template, $title, $requiredCols, $variables = null, $newGroup = null)
{
Assertion::string($template);
Assertion::string($title);
Assertion::integer($requiredCols);
Assertion::min($requiredCols, 1);
Assertion::max($requiredCols, 12);
$options = ['required_cols' => $requiredCols, 'title' => $title, 'new_group' => $newGroup];
$model = new self($variables, $options);
$model->setTemplate($template);
return $model;
}
示例11: __construct
public function __construct(CriteriaList $search_criteria_list, CriteriaList $filter_criteria_list, CriteriaList $sort_criteria_list, $offset, $limit)
{
Assertion::integer($offset);
Assertion::min($offset, 0);
Assertion::integer($limit);
Assertion::min($limit, 1);
$this->search_criteria_list = $search_criteria_list;
$this->filter_criteria_list = $filter_criteria_list;
$this->sort_criteria_list = $sort_criteria_list;
$this->offset = $offset;
$this->limit = $limit;
}
示例12: __construct
public function __construct($name, array $parameters, $offset, $limit)
{
Assertion::string($name);
Assertion::notEmpty($name);
Assertion::integer($offset);
Assertion::min($offset, 0);
Assertion::integer($limit);
Assertion::min($limit, 1);
$this->name = $name;
$this->parameters = $parameters;
$this->offset = $offset;
$this->limit = $limit;
}
示例13: __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;
}
示例14: __construct
/**
* RpcClientRequest constructor.
*
* @param array|string|integer|float|bool $payload
* @param string $server
* @param string $requestId
* @param string|null $routingKey
* @param int $expiration
* @param string|null $userId
* @param string|null $messageId
* @param string|null $timestamp
* @param string|null $type
*/
public function __construct($payload, $server, $requestId, $routingKey = null, $expiration = 0, $userId = null, $messageId = null, $timestamp = null, $type = null)
{
if (!is_array($payload) && !is_scalar($payload)) {
throw new Exception\InvalidArgumentException('$payload must be of type array or scalar');
}
Assertion::minLength($server, 1);
Assertion::minLength($requestId, 1);
Assertion::nullOrString($routingKey);
Assertion::min($expiration, 0);
Assertion::nullOrString($userId);
Assertion::nullOrString($messageId);
Assertion::nullOrString($timestamp);
Assertion::nullOrString($type);
$this->payload = $payload;
$this->server = $server;
$this->requestId = $requestId;
$this->routingKey = $routingKey;
$this->expiration = $expiration;
$this->userId = $userId;
$this->messageId = $messageId;
$this->timestamp = $timestamp;
$this->type = $type;
}
示例15: setLimit
/**
* Defines the amount of entities to be fetched from the information provider.
*
* @param integer $limit Positive integer defining the amount of records to be return in max. Zero (0) defines an unlimited amount.
*
* @throws \Assert\InvalidArgumentException in case the provided argument does not meet expectations.
*/
public function setLimit($limit)
{
$message = 'Given limit must be a positive number.';
Assertion::numeric($limit, $message);
Assertion::min($limit, 0, $message);
$this->limit = $limit;
}