class Character … private $level = 1; private $exp = 0; // クエリの例 public function getLevel(): int { return $this->level; } // クエリの例 public function getExpForNextLevel(): int { return 100 - $this->exp % 100; } }
class CharacterId { private $character_id; public function __construct(int $character_id) { $this->character_id = $character_id; } public function formatted(): string { return sprintf("P%05d", $this->character_id); } }
参考資料 ✘ Greg Young流CQRSの和訳版 ✘ Greg Young流CQRS - Mark Nijhof ✘ 副作用を最小限に抑えるために必要なこと ✘ オブジェクト指向入門 第2版 方法論・実践 ✘ Patterns of Enterprise Application Architecture ✘ 達人に学ぶSQL徹底指南書 ✘ Domain Model- P of EAA Catalog ✘ Transaction Script - P of EAA Catalog ✘ ValueObject - Martin Fowler