minLength() public static method

Assert that a string is at least $minLength chars long.
public static minLength ( mixed $value, integer $minLength, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean
$value mixed
$minLength integer
$message string | null
$propertyPath string | null
$encoding string
return boolean
 /**
  * @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;
     }
 }
Exemplo n.º 2
0
 /**
  * @param $text
  */
 public function __construct($text)
 {
     Assertion::string($text);
     Assertion::minLength($text, 1);
     Assertion::maxLength($text, 1000);
     $this->text = $text;
 }
Exemplo n.º 3
0
 /**
  * @param string $value
  */
 public function __construct($value)
 {
     Assertion::string($value);
     Assertion::minLength($value, 1);
     Assertion::maxLength($value, 50);
     $this->value = strtolower($value);
 }
Exemplo n.º 4
0
 /**
  * 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;
     }
 }
Exemplo n.º 6
0
 /**
  * @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;
 }
Exemplo n.º 7
0
 /**
  * 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();
 }
Exemplo n.º 8
0
 /**
  * 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;
     }
 }
Exemplo n.º 11
0
 public function hasMinLength($value, $minLength)
 {
     parent::minLength($value, $minLength);
 }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
 public function containsFuzzyContext($partial)
 {
     Assertion::string($partial);
     Assertion::minLength($partial, 1);
     return mb_strpos(json_encode($this->logContext), $partial) !== false;
 }
Exemplo n.º 14
0
 /**
  * Create a new Password
  *
  * @param string $value
  * @return void
  */
 public function __construct($value)
 {
     Assertion::minLength($value, 8);
     $this->value = $value;
 }
Exemplo n.º 15
0
 private function setName($name)
 {
     Assertion::minLength($name, 3, 'Chapter name must be at least 3 chars long');
     $this->name = $name;
 }
Exemplo n.º 16
0
 /**
  * @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());
     }
 }
Exemplo n.º 17
0
 /**
  * @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;
 }
Exemplo n.º 18
0
 /**
  * Add LogContextFuzzy.
  *
  * @param string $logContextFuzzy
  * @return LogQuery
  */
 public function withLogContextFuzzy($logContextFuzzy)
 {
     Assertion::string($logContextFuzzy);
     Assertion::minLength($logContextFuzzy, 1);
     return $this->immutableWith('logContextFuzzy', $logContextFuzzy);
 }
Exemplo n.º 19
0
 public function testValidMinLength()
 {
     Assertion::minLength("foo", 3);
     Assertion::minLength("foo", 1);
     Assertion::minLength("foo", 0);
     Assertion::minLength("", 0);
     Assertion::minLength("址址", 2);
 }
Exemplo n.º 20
0
 /**
  * @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);
     }
 }