uuid() public static method

Uses code from {@link https://github.com/ramsey/uuid} that is MIT licensed.
public static uuid ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean
 /**
  * @param string $workflowName
  * @param string $workflowId
  * @return CreateWorkflow
  */
 public static function withName($workflowName, $workflowId)
 {
     Assertion::string($workflowName);
     Assertion::notEmpty($workflowName);
     Assertion::uuid($workflowId);
     return new self(__CLASS__, ['workflow_id' => $workflowId, 'name' => $workflowName]);
 }
 public static function withData($workflowId, $previousTaskId, $nextMessageHandlerId)
 {
     Assertion::uuid($workflowId);
     Assertion::uuid($previousTaskId);
     Assertion::uuid($nextMessageHandlerId);
     return new self(__CLASS__, ['workflow_id' => $workflowId, 'previous_task_id' => $previousTaskId, 'next_message_handler_id' => $nextMessageHandlerId]);
 }
Beispiel #3
0
 public static function fromString($uuid)
 {
     Assertion::uuid($uuid);
     $patientId = new static();
     $patientId->id = $uuid;
     return $patientId;
 }
 /**
  * @param string $processId
  * @return null|array process log, see {@method getLastLoggedProcesses} for structure
  */
 public function getLoggedProcess($processId)
 {
     Assertion::uuid($processId);
     $query = $this->connection->createQueryBuilder();
     $query->select('*')->from(Tables::PROCESS_LOG)->where('process_id = :process_id')->setParameter('process_id', $processId);
     return $query->execute()->fetch();
 }
Beispiel #5
0
 /**
  * @param mixed $value
  *
  * @throws InvalidUuidException
  */
 protected function guard($value)
 {
     try {
         Assertion::uuid($value);
     } catch (\Exception $e) {
         throw new InvalidUuidException($value);
     }
 }
 /**
  * Creates a new identifier with the given UUID.
  *
  * @param Uuid|string $uuid
  */
 private function __construct($uuid)
 {
     if ($uuid instanceof Uuid) {
         $uuid = $uuid->toString();
     }
     Assertion::uuid($uuid);
     $this->uuid = (string) $uuid;
 }
Beispiel #7
0
 /**
  * @param string $gameId
  * @param string $word
  * @return Game
  */
 public static function gameStart($gameId, $word)
 {
     Assertion::uuid($gameId, "Not a valid uuid");
     $game = new Game();
     $dateTime = new \DateTime("now");
     $game->apply(new GameStarted($gameId, $word, $dateTime));
     return $game;
 }
 public function __construct($value = null)
 {
     if (!$value) {
         $value = BaseUuid::uuid4();
     }
     Assertion::uuid((string) $value);
     $this->value = (string) $value;
 }
Beispiel #9
0
 public function setUuidAttribute($value)
 {
     if ($value instanceof UuidIdentifier) {
         $value = $value->toString();
     }
     Assertion::uuid($value, 'Invalid format for UUID');
     $this->attributes['uuid'] = $value;
 }
Beispiel #10
0
 /**
  * @param UuidInterface $id
  * @param int $amount
  * @param Product $product
  */
 public function __construct(UuidInterface $id, $amount, Product $product)
 {
     Assertion::uuid($id->toString());
     Assertion::integer($amount);
     Assertion::notEmpty($product);
     $this->id = $id;
     $this->amount = $amount;
     $this->product = $product;
 }
 protected function guardRequiredState()
 {
     parent::guardRequiredState();
     Assertion::string($this->parent_attribute_name);
     Assertion::string($this->embedded_entity_type);
     Assertion::uuid($this->embedded_entity_identifier);
     Assertion::isArray($this->embedded_entity_events);
     Assertion::isArray($this->data);
 }
Beispiel #12
0
 /**
  * GitLab constructor.
  *
  * @param             $id
  * @param             $name
  * @param             $url
  * @param array       $authData
  * @param GitLab\AuthInterface $auth
  *
  * @throws \Assert\AssertionFailedException
  */
 public function __construct($id, $name, $url, array $authData, GitLab\AuthInterface $auth)
 {
     Assertion::uuid($id);
     $this->id = $id;
     $this->setAuthData(new ArrayCollection($authData));
     $this->setName($name);
     $this->setUrl($url);
     $this->setAuth($auth);
 }
 /**
  * @param string $basketId
  *
  * @return Response
  */
 public function removeProductFromBasketAction(Request $request, $basketId)
 {
     $basketId = new BasketId($basketId);
     $productToRemove = $request->request->get('productId');
     Assert::uuid($productToRemove);
     $command = new RemoveProductFromBasket($basketId, $productToRemove);
     $this->commandBus->dispatch($command);
     return new Response();
 }
 /**
  * @param string $workflowId
  * @param array $startMessage
  * @param string $firstMessageHandlerId
  * @return ScheduleFirstTasksForWorkflow
  */
 public static function withData($workflowId, $startMessage, $firstMessageHandlerId)
 {
     Assertion::uuid($workflowId);
     Assertion::uuid($firstMessageHandlerId);
     Assertion::isArray($startMessage);
     Assertion::keyExists($startMessage, 'message_type');
     Assertion::keyExists($startMessage, 'processing_type');
     $processingType = $startMessage['processing_type'];
     Assertion::implementsInterface($processingType, Type::class);
     return new self(__CLASS__, ['workflow_id' => $workflowId, 'start_message' => $startMessage, 'first_message_handler' => $firstMessageHandlerId]);
 }
 /**
  * BaseReport constructor.
  *
  * @param BaseReportBuilder $builder
  *
  * @throws \Assert\AssertionFailedException
  */
 public function __construct(BaseReportBuilder $builder)
 {
     $id = $builder->getId();
     Assertion::uuid($id);
     $this->id = $id;
     $name = $builder->getName();
     Assertion::string($name);
     Assertion::notEmpty($name);
     $this->name = $name;
     $description = $builder->getDescription();
     Assertion::nullOrString($description);
     $this->setDescription($description);
     $gitLab = $builder->getGitLab();
     Assertion::isInstanceOf($gitLab, GitLab::class);
     $this->gitLab = $gitLab;
 }
 /**
  * @param UuidInterface $id
  * @param int $type
  * @param string $street
  * @param string $streetNumber
  * @param string $postalCode
  * @param string $city
  * @param string $state
  * @param string $country
  * @param string $phone
  */
 public function __construct(UuidInterface $id, $type, $street, $streetNumber, $postalCode, $city, $state, $country, $phone)
 {
     Assertion::uuid($id->toString());
     Assertion::choice($type, [self::TYPE_BILLING, self::TYPE_SHIPPING]);
     Assertion::notEmpty($street);
     Assertion::notEmpty($streetNumber);
     Assertion::notEmpty($postalCode);
     Assertion::notEmpty($city);
     Assertion::notEmpty($state);
     Assertion::notEmpty($country);
     Assertion::notEmpty($phone);
     $this->id = $id;
     $this->type = $type;
     $this->street = $street;
     $this->streetNumber = $streetNumber;
     $this->postalCode = $postalCode;
     $this->city = $city;
     $this->state = $state;
     $this->country = $country;
     $this->phone = $phone;
 }
 /**
  * @param string $messageHandlerId
  * @param string $name
  * @param string $nodeName
  * @param string $handlerType
  * @param string $dataDirection
  * @param array|string $supportedProcessingTypes
  * @param array $processingMetadata
  * @param string $metadataRiotTag
  * @param string $icon
  * @param string $iconType
  * @param null|string $preferredProcessingType
  * @param null|string $handlerProcessingId
  * @param array $additionalData
  * @return InstallMessageHandler
  */
 public static function withData($messageHandlerId, $name, $nodeName, $handlerType, $dataDirection, $supportedProcessingTypes, array $processingMetadata, $metadataRiotTag, $icon, $iconType, $preferredProcessingType = null, $handlerProcessingId = null, array $additionalData = [])
 {
     Assertion::uuid($messageHandlerId);
     Assertion::string($name);
     Assertion::notEmpty($name);
     Assertion::string($nodeName);
     Assertion::notEmpty($nodeName);
     Assertion::string($handlerType);
     Assertion::string($dataDirection);
     Assertion::string($metadataRiotTag);
     Assertion::string($icon);
     Assertion::string($iconType);
     if (!is_null($preferredProcessingType)) {
         Assertion::string($preferredProcessingType);
         Assertion::implementsInterface($preferredProcessingType, Type::class);
     }
     if (!is_null($handlerProcessingId)) {
         Assertion::string($handlerProcessingId);
     }
     if (!is_string($supportedProcessingTypes)) {
         Assertion::isArray($supportedProcessingTypes);
     }
     return new self(__CLASS__, ['message_handler_id' => $messageHandlerId, 'name' => $name, 'node_name' => $nodeName, 'handler_type' => $handlerType, 'data_direction' => $dataDirection, 'supported_processing_types' => $supportedProcessingTypes, 'processing_metadata' => $processingMetadata, 'metadata_riot_tag' => $metadataRiotTag, 'icon' => $icon, 'icon_type' => $iconType, 'preferred_processing_type' => $preferredProcessingType, 'handler_processing_id' => $handlerProcessingId, 'additional_data' => $additionalData]);
 }
Beispiel #18
0
 /**
  * GitLab constructor.
  *
  * @param $id
  *
  * @throws \Assert\AssertionFailedException
  */
 public function __construct($id)
 {
     Assertion::uuid($id);
     $this->id = $id;
 }
Beispiel #19
0
 protected function guardRequiredState()
 {
     Assertion::uuid($this->uuid);
     Assertion::isArray($this->metadata);
 }
 /**
  * @param string $trackingId
  */
 public function setTrackingId(string $trackingId)
 {
     Assertion::uuid($trackingId);
     $this->trackingId = $trackingId;
 }
 /**
  * @test
  */
 public function it_dispatches_events_when_no_state_is_found()
 {
     $this->handleEvent($this->manager, new TestEvent2());
     $dispatchedEvents = $this->eventDispatcher->getDispatchedEvents();
     $this->assertCount(2, $dispatchedEvents);
     $this->assertEquals('broadway.saga.pre_handle', $dispatchedEvents[0]['event']);
     $this->assertEquals('sagaId', $dispatchedEvents[0]['arguments'][0]);
     Assert::uuid($dispatchedEvents[0]['arguments'][1]);
     $this->assertEquals('broadway.saga.post_handle', $dispatchedEvents[1]['event']);
     $this->assertEquals('sagaId', $dispatchedEvents[1]['arguments'][0]);
     Assert::uuid($dispatchedEvents[1]['arguments'][1]);
     $this->assertEquals($dispatchedEvents[0]['arguments'][1], $dispatchedEvents[1]['arguments'][1]);
 }
 /**
  * @param string $processId
  * @param int $minVersion
  * @return DomainEvent[]
  */
 public function getStreamOfProcess($processId, $minVersion = 0)
 {
     Assertion::uuid($processId);
     return $this->eventStore->loadEventsByMetadataFrom(new StreamName('prooph_processing_stream'), ['aggregate_id' => $processId], $minVersion);
 }
Beispiel #23
0
 /**
  * Create a new API client.
  *
  * @param string $apiKey Your API key.
  * @return Client
  */
 public static function createClient($apiKey)
 {
     Guard::uuid(static::apiKeyToUuid($apiKey), 'Ginger API key is invalid: ' . $apiKey);
     return new Client(new HttpClient(['base_url' => [self::ENDPOINT, ['version' => self::API_VERSION]], 'defaults' => ['headers' => ['User-Agent' => 'ginger-php/' . self::CLIENT_VERSION, 'X-PHP-Version' => PHP_VERSION], 'auth' => [$apiKey, '']]]));
 }
Beispiel #24
0
 /**
  * @param string $basketId
  */
 public function __construct($basketId)
 {
     Assert::string($basketId);
     Assert::uuid($basketId);
     $this->basketId = $basketId;
 }
 /**
  * Удаляет гитлаб
  *
  * @param $gitLabId
  *
  * @return mixed
  * @throws \Exception
  * @throws \Assert\AssertionFailedException
  */
 public function deleteGitLab($gitLabId)
 {
     Assertion::uuid($gitLabId);
     $transactionManager = $this->getTransactionManager();
     try {
         $transactionManager->beginTransaction();
         $this->getGitLabRepository()->remove($gitLabId);
         $transactionManager->commit();
     } catch (\Exception $ex) {
         $transactionManager->rollback();
         throw $ex;
     }
 }
 protected function guardRequiredState()
 {
     parent::guardRequiredState();
     Assertion::uuid($this->embedded_entity_identifier);
 }
Beispiel #27
0
 /**
  * @dataProvider providesInvalidUuids
  */
 public function testInvalidUuids($uuid)
 {
     $this->setExpectedException('Assert\\InvalidArgumentException');
     Assertion::uuid($uuid);
 }
 /**
  * Устанавливает id сущности
  *
  * @param string $id
  *
  * @return $this
  * @throws \Assert\AssertionFailedException
  */
 public function setId($id)
 {
     Assertion::uuid($id);
     $this->id = $id;
     return $this;
 }
Beispiel #29
0
 protected function guardRequiredState()
 {
     Assertion::date($this->iso_date, self::DATE_ISO8601_WITH_MICROS);
     Assertion::uuid($this->uuid);
     Assertion::isArray($this->metadata);
 }
 /**
  * @test
  */
 public function shouldGenerateAnUuidIdOnGenerateIdentity()
 {
     $identifier = new IdentifierService(new IdentityBuilder());
     $this->assertNull(Assertion::uuid($identifier->generateIdentity()->id()));
 }