/** * @param null|string $identifierMethodName * @param null|string $versionMethodName * @param null|string $popRecordedEventsMethodName * @param null|string $replayEventsMethodsName * @param null|string $staticReconstituteFromHistoryMethodName * @param null|callable $eventToMessageCallback * @param null|callable $messageToEventCallback */ public function __construct($identifierMethodName = null, $versionMethodName = null, $popRecordedEventsMethodName = null, $replayEventsMethodsName = null, $staticReconstituteFromHistoryMethodName = null, $eventToMessageCallback = null, $messageToEventCallback = null) { if (null !== $identifierMethodName) { Assertion::minLength($identifierMethodName, 1, 'Identifier method name needs to be a non empty string'); $this->identifierMethodName = $identifierMethodName; } if (null !== $versionMethodName) { Assertion::minLength($versionMethodName, 1, 'Version method name needs to be a non empty string'); $this->versionMethodName = $versionMethodName; } if (null !== $popRecordedEventsMethodName) { Assertion::minLength($popRecordedEventsMethodName, 1, 'Pop recorded events method name needs to be a non empty string'); $this->popRecordedEventsMethodName = $popRecordedEventsMethodName; } if (null !== $replayEventsMethodsName) { Assertion::minLength($replayEventsMethodsName, 1, 'Replay events method name needs to be a non empty string'); $this->replayEventsMethodName = $replayEventsMethodsName; } if (null !== $staticReconstituteFromHistoryMethodName) { Assertion::minLength($staticReconstituteFromHistoryMethodName, 1, 'Method name for static method reconstitute from history needs to be non empty string'); $this->staticReconstituteFromHistoryMethodName = $staticReconstituteFromHistoryMethodName; } if (null !== $eventToMessageCallback) { Assertion::true(is_callable($eventToMessageCallback), 'EventToMessage callback needs to be a callable'); $this->eventToMessageCallback = $eventToMessageCallback; } if (null !== $messageToEventCallback) { Assertion::true(is_callable($messageToEventCallback), 'MessageToEvent callback needs to be a callable'); $this->messageToEventCallback = $messageToEventCallback; } }
/** * @param $text */ public function __construct($text) { Assertion::string($text); Assertion::minLength($text, 1); Assertion::maxLength($text, 1000); $this->text = $text; }
/** * @param string $value */ public function __construct($value) { Assertion::string($value); Assertion::minLength($value, 1); Assertion::maxLength($value, 50); $this->value = strtolower($value); }
/** * 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; } }
/** * @param MongoClient $mongoClient * @param string $dbName * @param array|null $writeConcern * @param array $snapshotGridFsMap */ public function __construct(MongoClient $mongoClient, $dbName, array $writeConcern = null, array $snapshotGridFsMap = []) { Assertion::minLength($dbName, 1, 'Mongo database name is missing'); $this->mongoClient = $mongoClient; $this->dbName = $dbName; $this->snapshotGridFsMap = $snapshotGridFsMap; if (null !== $writeConcern) { $this->writeConcern = $writeConcern; } }
/** * @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; }
/** * JsonRpcRequest constructor. * * @param string $server * @param string $method * @param array|string|integer|float|bool $params * @param string $routingKey * @param int $expiration in milliseconds * @param string|null $id * @param int $timestamp */ public function __construct(string $server, string $method, $params, string $id = null, string $routingKey = '', int $expiration = 0, int $timestamp = 0) { if (!is_array($params) && !is_scalar($params) && null !== $params) { throw new Exception\InvalidArgumentException('Params must be of type array, scalar or null'); } Assertion::minLength($server, 1); $this->server = $server; $this->method = $method; $this->params = $params; $this->id = $id; $this->routingKey = $routingKey; $this->expiration = $expiration; $this->timestamp = 0 === $timestamp ? $timestamp : time(); }
/** * 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; }
/** * @param string $text */ private function __construct($text) { Assertion::minLength($text, 1, 'Success message must be at least 1 char long'); $this->text = $text; $this->init(); }
/** * @param MessageFactory $messageFactory * @param MessageConverter $messageConverter * @param \MongoClient $mongoClient * @param string $dbName * @param array|null $writeConcern * @param string|null $streamCollectionName * @param int|null $transactionTimeout */ public function __construct(MessageFactory $messageFactory, MessageConverter $messageConverter, \MongoClient $mongoClient, $dbName, array $writeConcern = null, $streamCollectionName = null, $transactionTimeout = null) { Assertion::minLength($dbName, 1, 'Mongo database name is missing'); $this->messageFactory = $messageFactory; $this->messageConverter = $messageConverter; $this->mongoClient = $mongoClient; $this->dbName = $dbName; if (null !== $streamCollectionName) { Assertion::minLength($streamCollectionName, 1, 'Stream collection name must be a string with min length 1'); $this->streamCollectionName = $streamCollectionName; } if (null !== $writeConcern) { $this->writeConcern = $writeConcern; } if (null !== $transactionTimeout) { Assertion::min($transactionTimeout, 1, 'Transaction timeout must be a positive integer'); $this->transactionTimeout = $transactionTimeout; } }
public function hasMinLength($value, $minLength) { parent::minLength($value, $minLength); }
public function __construct($aName) { Assertion::string($aName, sprintf("An EventName must be a string %s given", Util::getType($aName))); Assertion::minLength($aName, 5, sprintf("An EventName must be at least 5 chars long, less given in: %s", $aName)); $this->name = $aName; }
public function containsFuzzyContext($partial) { Assertion::string($partial); Assertion::minLength($partial, 1); return mb_strpos(json_encode($this->logContext), $partial) !== false; }
/** * Create a new Password * * @param string $value * @return void */ public function __construct($value) { Assertion::minLength($value, 8); $this->value = $value; }
private function setName($name) { Assertion::minLength($name, 3, 'Chapter name must be at least 3 chars long'); $this->name = $name; }
/** * @param string $text * @throws Exception\InvalidText */ private function assertText($text) { try { Assertion::string($text); Assertion::minLength($text, 3); } catch (\Exception $e) { throw Exception\InvalidText::reason($e->getMessage()); } }
/** * @param string $name */ public function __construct($name) { Assertion::string($name, "Action.name must be a string"); Assertion::minLength($name, 5, "Action.name must at least be 5 chars long"); $this->name = $name; }
/** * Add LogContextFuzzy. * * @param string $logContextFuzzy * @return LogQuery */ public function withLogContextFuzzy($logContextFuzzy) { Assertion::string($logContextFuzzy); Assertion::minLength($logContextFuzzy, 1); return $this->immutableWith('logContextFuzzy', $logContextFuzzy); }
public function testValidMinLength() { Assertion::minLength("foo", 3); Assertion::minLength("foo", 1); Assertion::minLength("foo", 0); Assertion::minLength("", 0); Assertion::minLength("址址", 2); }
/** * @param array $metadata */ public static function assertMetadata($metadata) { Assertion::isArray($metadata, 'metadata must be an array'); foreach ($metadata as $key => $value) { Assertion::minLength($key, 1, 'A metadata key must be non empty string'); Assertion::scalar($value, 'A metadata value must have a scalar type. Got ' . gettype($value) . ' for ' . $key); } }