/** * {@inheritdoc} */ public function getSnapshot(UuidInterface $id) { if (!isset($this->snapshots[$id->toString()])) { return null; } return $this->snapshots[$id->toString()]; }
public function getByUuid(UuidInterface $uuid) : Token { return $this->getTokenFromRow($this->getRow(' SELECT token_uuid, pass_code, user_uuid, expires FROM tokens WHERE token_uuid = :token_uuid ', ['token_uuid' => $uuid->getBytes()])); }
/** * @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; }
public function getByUuid(UuidInterface $uuid) : User { return $this->getUserFromRow($this->getRow(' SELECT user_uuid, email_address, password, display_name, created, updated FROM users INNER JOIN objects ON (user_uuid = uuid AND type = "users") WHERE user_uuid = :user_uuid ', ['user_uuid' => $uuid->getBytes()])); }
/** * {@inheritdoc} */ public function getCommittedEventStream(UuidInterface $id, $version = 0) { $eventStream = new EventStream($id); if (isset($this->committedEvents[$id->toString()])) { foreach ($this->committedEvents[$id->toString()] as $event) { $eventStream->push($event); } } return $eventStream; }
public function getByUuid(UuidInterface $uuid) : Page { $page = $this->getPageFromRow($this->getRow(' SELECT page_uuid, title, slug, short_title, parent_uuid, sort_order, status, created, updated FROM pages INNER JOIN objects ON (page_uuid = uuid AND type = "pages") WHERE page_uuid = :page_uuid ', ['page_uuid' => $uuid->getBytes()])); $this->getBlocksForPages([$page]); return $page; }
/** * {@inheritdoc} */ public function getSnapshot(UuidInterface $id) { try { $cursor = $this->client->selectCollection($this->options->getDatabase(), $id->toString())->find()->sort(['$natural' => -1])->limit(1); } catch (\Exception $e) { throw new EventStoreException(__METHOD__ . ' : ' . $e->getMessage()); } $snapshot = $cursor->current(); if (!isset($snapshot)) { return null; } $eventProvider = $this->serializer->deserialize($snapshot['memento']['data'], $snapshot['memento']['type'], 'json'); return $eventProvider; }
/** * {@inheritdoc} */ public function getCommittedEventStream(UuidInterface $id, $version = 0) { if (0 < $version) { $query = ['version' => ['$gte' => $version]]; } else { $query = []; } try { $cursor = $this->connection->selectCollection($this->options->getDatabase(), $id->toString())->find($query); } catch (\Exception $e) { throw new EventStoreException(__METHOD__ . ' : ' . $e->getMessage()); } $eventStream = new EventStream($id); foreach ($cursor as $document) { /** @var Event $event */ $event = $this->serializer->deserialize($document['data']['payload'], $document['data']['type'], 'json'); $eventStream->push($event); } return $eventStream; }
/** * @param null|UuidInterface $previousEventId * @return Generator */ public function iterate(UuidInterface $previousEventId = null) { $id = $previousEventId ? $previousEventId->toString() : null; while (true) { $response = $this->getFromApi($id, $this->requestLimit); $events = $response ? $response['_embedded']['event'] : null; if (!$events) { break; } $lastId = false; foreach ($events as $event) { $lastId = $event['id']; (yield $this->fromArray($event)); } if ($response['count'] < $this->requestLimit || !$lastId) { break; } $id = $lastId; } }
/** * @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; }
public function getContent(UuidInterface $uuid) { return array(array('', 'content:', 'time: ' . $uuid->getDateTime()->format('c')), array('', '', 'clock: ' . $uuid->getClockSequence() . ' (usually random)'), array('', '', 'node: ' . substr(chunk_split($uuid->getNodeHex(), 2, ':'), 0, -1))); }
/** * Encodes a UuidInterface as a string representation of a timestamp first COMB UUID * * @param UuidInterface $uuid * * @return string Hexadecimal string representation of a GUID */ public function encode(UuidInterface $uuid) { $sixPieceComponents = array_values($uuid->getFieldsHex()); $this->swapTimestampAndRandomBits($sixPieceComponents); return vsprintf('%08s-%04s-%04s-%02s%02s-%012s', $sixPieceComponents); }
/** * @param string $msgType * @return array */ private function createHeader($msgType) { return ['date' => (new \DateTime('NOW'))->format('c'), 'msg_id' => Uuid::uuid4()->toString(), 'username' => "kernel", 'session' => $this->sesssionId->toString(), 'msg_type' => $msgType]; }
/** * {@inheritdoc} */ public function toString() { return $this->uuid->toString(); }
/** * {@inheritdoc} */ public function isEqualTo(ValueObject $object) : bool { return $object instanceof TicketTypeId && $object->toString() === $this->id->toString(); }
/** * @return string */ public function toString() : string { return $this->value->toString(); }
/** * Returns content as an array of rows, each row being an array containing column values. */ public function getContent(UuidInterface $uuid) { $formatter = self::$formatters[$uuid->getVersion()]; return $formatter->getContent($uuid); }
public function getContent(UuidInterface $uuid) { return array(array('', 'content:', substr(chunk_split($uuid->getHex(), 2, ':'), 0, -1)), array('', '', '(not decipherable: MD5 message digest only)')); }
/** * {@inheritdoc} */ public function set(UuidInterface $id, EventStream $eventStream) { $this->eventStreams[$id->toString()] = $eventStream; }
public function compareTo(UuidInterface $other) { $comparison = 0; if ($this->getMostSignificantBitsHex() < $other->getMostSignificantBitsHex()) { $comparison = -1; } elseif ($this->getMostSignificantBitsHex() > $other->getMostSignificantBitsHex()) { $comparison = 1; } elseif ($this->getLeastSignificantBitsHex() < $other->getLeastSignificantBitsHex()) { $comparison = -1; } elseif ($this->getLeastSignificantBitsHex() > $other->getLeastSignificantBitsHex()) { $comparison = 1; } return $comparison; }
/** * Returns the UUID serialized for JSON. * * @param JsonSerializationVisitor $visitor The serialization visitor. * @param UuidInterface $uuid The UUID to serialize. * @param array $type The type information. * @param Context $context The serialization context. * * @return string The serialized UUID. */ public static function toJson(JsonSerializationVisitor $visitor, UuidInterface $uuid, array $type, Context $context) { return $uuid->toString(); }
public function encodeBinary(UuidInterface $uuid) { $components = array_values($uuid->getFieldsHex()); return hex2bin(implode('', $components)); }
/** * Encodes a UUID into a string (LSB first) according to the alphabet * If leftmost (MSB) bits 0, string might be shorter * * @param UuidInterface $uuid * @return string */ public function encode($uuid) { $padLength = $this->encodedLength(strlen($uuid->getBytes())); return $this->numToString($uuid->getInteger(), $padLength); }
/** * @param UuidInterface $id * @return null|CartEntry */ public function getEntry(UuidInterface $id) { return isset($this->entries[$id->toString()]) ? $this->entries[$id->toString()] : null; }
/** * Encodes a UuidInterface as an optimized binary representation of a UUID * * @param UuidInterface $uuid * @return string Binary string representation of a UUID */ public function encodeBinary(UuidInterface $uuid) { $fields = $uuid->getFieldsHex(); $optimized = [$fields['time_hi_and_version'], $fields['time_mid'], $fields['time_low'], $fields['clock_seq_hi_and_reserved'], $fields['clock_seq_low'], $fields['node']]; return hex2bin(implode('', $optimized)); }
/** @return void */ public function delete(string $type, UuidInterface $uuid) { $this->pdo->prepare('DELETE FROM objects WHERE uuid = :uuid AND type = :type')->execute(['uuid' => $uuid->getBytes(), 'type' => $type]); }
/** * Encodes a UuidInterface as a binary representation of a UUID * * @param UuidInterface $uuid * @return string Binary string representation of a UUID */ public function encodeBinary(UuidInterface $uuid) { return hex2bin($uuid->getHex()); }
/** @return resource */ private function getFileStream(UuidInterface $fileUuid) { $stream = $this->fileSystem->readStream($fileUuid->toString()); if (!$stream) { throw new \RuntimeException('Could not retrieve stream for file.'); } return $stream; }
/** * @param \JMS\Serializer\VisitorInterface $visitor * @param \Ramsey\Uuid\UuidInterface $uuid * @param mixed[] $type * @param \JMS\Serializer\Context $context * @return string */ public function serializeUuid(VisitorInterface $visitor, UuidInterface $uuid, array $type, Context $context) { return $visitor->visitString($uuid->toString(), $type, $context); }
/** * @param UuidInterface $id * @return null|Cart */ public function getCart(UuidInterface $id) { return isset($this->carts[$id->toString()]) ? $this->carts[$id->toString()] : null; }