コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getSnapshot(UuidInterface $id)
 {
     if (!isset($this->snapshots[$id->toString()])) {
         return null;
     }
     return $this->snapshots[$id->toString()];
 }
コード例 #2
0
 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()]));
 }
コード例 #3
0
ファイル: CartEntry.php プロジェクト: palya-framework/palya
 /**
  * @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;
 }
コード例 #4
0
 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()]));
 }
コード例 #5
0
 /**
  * {@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;
 }
コード例 #6
0
 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;
 }
コード例 #7
0
 /**
  * {@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;
 }
コード例 #8
0
 /**
  * {@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;
 }
コード例 #9
0
ファイル: GuzzleApiEventStore.php プロジェクト: pauci/cqrs
 /**
  * @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;
     }
 }
コード例 #10
0
 /**
  * @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;
 }
コード例 #11
0
ファイル: V1Formatter.php プロジェクト: ramsey/uuid-console
 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)));
 }
コード例 #12
0
 /**
  * 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);
 }
コード例 #13
0
ファイル: JupyterBroker.php プロジェクト: Litipk/Jupyter-PHP
 /**
  * @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];
 }
コード例 #14
0
ファイル: UuidIdentifier.php プロジェクト: gdbots/common-php
 /**
  * {@inheritdoc}
  */
 public function toString()
 {
     return $this->uuid->toString();
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 public function isEqualTo(ValueObject $object) : bool
 {
     return $object instanceof TicketTypeId && $object->toString() === $this->id->toString();
 }
コード例 #16
0
 /**
  * @return string
  */
 public function toString() : string
 {
     return $this->value->toString();
 }
コード例 #17
0
ファイル: UuidFormatter.php プロジェクト: ramsey/uuid-console
 /**
  * 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);
 }
コード例 #18
0
ファイル: V3Formatter.php プロジェクト: ramsey/uuid-console
 public function getContent(UuidInterface $uuid)
 {
     return array(array('', 'content:', substr(chunk_split($uuid->getHex(), 2, ':'), 0, -1)), array('', '', '(not decipherable: MD5 message digest only)'));
 }
コード例 #19
0
 /**
  * {@inheritdoc}
  */
 public function set(UuidInterface $id, EventStream $eventStream)
 {
     $this->eventStreams[$id->toString()] = $eventStream;
 }
コード例 #20
0
ファイル: Uuid.php プロジェクト: rodion-k/uuid
 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;
 }
コード例 #21
0
ファイル: UuidHandler.php プロジェクト: kherge/uuid-bundle
 /**
  * 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();
 }
コード例 #22
0
ファイル: GuidStringCodec.php プロジェクト: jacko972/uuid
 public function encodeBinary(UuidInterface $uuid)
 {
     $components = array_values($uuid->getFieldsHex());
     return hex2bin(implode('', $components));
 }
コード例 #23
0
ファイル: ShortUUID.php プロジェクト: pyyoshi/shortuuid-php
 /**
  * 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);
 }
コード例 #24
0
ファイル: Cart.php プロジェクト: palya-framework/palya
 /**
  * @param UuidInterface $id
  * @return null|CartEntry
  */
 public function getEntry(UuidInterface $id)
 {
     return isset($this->entries[$id->toString()]) ? $this->entries[$id->toString()] : null;
 }
コード例 #25
0
ファイル: OrderedTimeCodec.php プロジェクト: ramsey/uuid
 /**
  * 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));
 }
コード例 #26
0
 /** @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]);
 }
コード例 #27
0
ファイル: StringCodec.php プロジェクト: 00f100/uuid
 /**
  * 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());
 }
コード例 #28
0
 /** @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;
 }
コード例 #29
0
 /**
  * @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);
 }
コード例 #30
0
ファイル: Customer.php プロジェクト: palya-framework/palya
 /**
  * @param UuidInterface $id
  * @return null|Cart
  */
 public function getCart(UuidInterface $id)
 {
     return isset($this->carts[$id->toString()]) ? $this->carts[$id->toString()] : null;
 }