diff --git a/src/Lending/DailySheet/Model/CheckoutsToOverdueSheet.php b/src/Lending/DailySheet/Model/CheckoutsToOverdueSheet.php new file mode 100644 index 0000000..d4654f9 --- /dev/null +++ b/src/Lending/DailySheet/Model/CheckoutsToOverdueSheet.php @@ -0,0 +1,32 @@ + $checkouts + */ + public function __construct(public GenericList $checkouts) + { + } + + /** + * @return Stream + */ + public function toStreamOfEvents(): Stream + { + return $this->checkouts->toStream()->map(fn (OverdueCheckout $oc) => $oc->toEvent()); + } + + public function count(): int + { + return $this->checkouts->length(); + } +} diff --git a/src/Lending/DailySheet/Model/DailySheet.php b/src/Lending/DailySheet/Model/DailySheet.php new file mode 100644 index 0000000..5471e85 --- /dev/null +++ b/src/Lending/DailySheet/Model/DailySheet.php @@ -0,0 +1,28 @@ +patronId, $this->bookId, $this->libraryBranchId); + } +} diff --git a/src/Lending/DailySheet/Model/HoldsToExpireSheet.php b/src/Lending/DailySheet/Model/HoldsToExpireSheet.php new file mode 100644 index 0000000..dda6f05 --- /dev/null +++ b/src/Lending/DailySheet/Model/HoldsToExpireSheet.php @@ -0,0 +1,32 @@ + $expireHolds + */ + public function __construct(public GenericList $expireHolds) + { + } + + /** + * @return Stream + */ + public function toStreamOfEvents(): Stream + { + return $this->expireHolds->toStream()->map(fn (ExpiredHold $eh) => $eh->toEvent()); + } + + public function count(): int + { + return $this->expireHolds->length(); + } +} diff --git a/src/Lending/DailySheet/Model/OverdueCheckout.php b/src/Lending/DailySheet/Model/OverdueCheckout.php new file mode 100644 index 0000000..04f91b1 --- /dev/null +++ b/src/Lending/DailySheet/Model/OverdueCheckout.php @@ -0,0 +1,22 @@ +patronId, $this->bookId, $this->libraryBranchId); + } +} diff --git a/src/Lending/Patron/Domain/PatronEvent/BookHoldCanceled.php b/src/Lending/Patron/Domain/PatronEvent/BookHoldCanceled.php new file mode 100644 index 0000000..b75f155 --- /dev/null +++ b/src/Lending/Patron/Domain/PatronEvent/BookHoldCanceled.php @@ -0,0 +1,54 @@ +patronId; + } + + public function eventId(): UUID + { + return $this->eventId; + } + + public function aggregateId(): UUID + { + return $this->patronId->patronId; + } + + public function when(): \DateTimeImmutable + { + return $this->when; + } +} diff --git a/src/Lending/Patron/Domain/PatronEvent/BookHoldExpired.php b/src/Lending/Patron/Domain/PatronEvent/BookHoldExpired.php new file mode 100644 index 0000000..e2e55c0 --- /dev/null +++ b/src/Lending/Patron/Domain/PatronEvent/BookHoldExpired.php @@ -0,0 +1,54 @@ +patronId; + } + + public function aggregateId(): UUID + { + return $this->patronId->patronId; + } + + public function eventId(): UUID + { + return $this->eventId; + } + + public function when(): \DateTimeImmutable + { + return $this->when; + } +} diff --git a/src/Lending/Patron/Domain/PatronEvent/BookReturned.php b/src/Lending/Patron/Domain/PatronEvent/BookReturned.php new file mode 100644 index 0000000..dd84060 --- /dev/null +++ b/src/Lending/Patron/Domain/PatronEvent/BookReturned.php @@ -0,0 +1,57 @@ +patronId; + } + + public function aggregateId(): UUID + { + return $this->patronId->patronId; + } + + public function eventId(): UUID + { + return $this->eventId; + } + + public function when(): \DateTimeImmutable + { + return $this->when; + } +} diff --git a/src/Lending/Patron/Domain/PatronEvent/OverdueCheckoutRegistered.php b/src/Lending/Patron/Domain/PatronEvent/OverdueCheckoutRegistered.php new file mode 100644 index 0000000..138a546 --- /dev/null +++ b/src/Lending/Patron/Domain/PatronEvent/OverdueCheckoutRegistered.php @@ -0,0 +1,54 @@ +patronId; + } + + public function eventId(): UUID + { + return $this->eventId; + } + + public function aggregateId(): UUID + { + return $this->patronId->patronId; + } + + public function when(): \DateTimeImmutable + { + return $this->when; + } +} diff --git a/tests/Unit/Lending/DailySheet/Model/CheckoutsToOverdueSheetTest.php b/tests/Unit/Lending/DailySheet/Model/CheckoutsToOverdueSheetTest.php new file mode 100644 index 0000000..da3aeb4 --- /dev/null +++ b/tests/Unit/Lending/DailySheet/Model/CheckoutsToOverdueSheetTest.php @@ -0,0 +1,35 @@ +toStreamOfEvents()->toArray(); + + self::assertTrue($events[0]->bookId->bookId->isEqual($bookId->bookId)); + self::assertTrue($events[0]->patronId->patronId->isEqual($patronId->patronId)); + self::assertTrue($events[0]->libraryBranchId->libraryBranchId->isEqual($libraryBranchId->libraryBranchId)); + + self::assertTrue($events[1]->bookId->bookId->isEqual($anotherBookId->bookId)); + self::assertTrue($events[1]->patronId->patronId->isEqual($anotherPatronId->patronId)); + self::assertTrue($events[1]->libraryBranchId->libraryBranchId->isEqual($anotherLibraryBranchId->libraryBranchId)); + } +} diff --git a/tests/Unit/Lending/DailySheet/Model/HoldsToExpireSheetTest.php b/tests/Unit/Lending/DailySheet/Model/HoldsToExpireSheetTest.php new file mode 100644 index 0000000..e1654db --- /dev/null +++ b/tests/Unit/Lending/DailySheet/Model/HoldsToExpireSheetTest.php @@ -0,0 +1,35 @@ +toStreamOfEvents()->toArray(); + + self::assertTrue($events[0]->bookId->bookId->isEqual($bookId->bookId)); + self::assertTrue($events[0]->patronId->patronId->isEqual($patronId->patronId)); + self::assertTrue($events[0]->libraryBranchId->libraryBranchId->isEqual($libraryBranchId->libraryBranchId)); + + self::assertTrue($events[1]->bookId->bookId->isEqual($anotherBookId->bookId)); + self::assertTrue($events[1]->patronId->patronId->isEqual($anotherPatronId->patronId)); + self::assertTrue($events[1]->libraryBranchId->libraryBranchId->isEqual($anotherLibraryBranchId->libraryBranchId)); + } +}