/** * @param UserId $assigneeId * @param string $text * @param TodoId $todoId * @param TodoStatus $todoStatus * @return TodoWasPosted */ public static function byUser(UserId $assigneeId, $text, TodoId $todoId, TodoStatus $todoStatus) { $event = self::occur($todoId->toString(), ['assignee_id' => $assigneeId->toString(), 'text' => $text, 'status' => $todoStatus->toString()]); $event->todoId = $todoId; $event->assigneeId = $assigneeId; $event->todoStatus = $todoStatus; return $event; }
/** * @param UserId $userId * @param string $name * @param EmailAddress $emailAddress * @return UserWasRegistered */ public static function withData(UserId $userId, $name, EmailAddress $emailAddress) { Assertion::string($name); $event = self::occur($userId->toString(), ['name' => $name, 'email' => $emailAddress->toString()]); $event->userId = $userId; $event->username = $name; $event->emailAddress = $emailAddress; return $event; }
/** * @param UserId $userId * @return UserNotFound */ public static function withUserId(UserId $userId) { return new self(sprintf('User with id %s cannot be found.', $userId->toString())); }
/** * @return string representation of the unique identifier of the aggregate root */ protected function aggregateId() { return $this->userId->toString(); }
/** * @param UserId $other * @return bool */ public function sameValueAs(UserId $other) { return $this->toString() === $other->toString(); }
/** * @param UserId $userId * @return User */ public function get(UserId $userId) { return $this->getAggregateRoot($userId->toString()); }