Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active September 6, 2023 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcsee/36f0af6785ea36a05c3ec394fa71e4e8 to your computer and use it in GitHub Desktop.
Save mcsee/36f0af6785ea36a05c3ec394fa71e4e8 to your computer and use it in GitHub Desktop.
<?
final class BookItem {
function numberOfPages() { }
function language(): Language { }
function book(): Book { }
function edition(): BookEdition { }
// Loan and overdues are not book items responsibility
}
final class LoanTracker {
function loan(
BookItem $bookCopy,
LibraryUser $reader,
DatePeriod $loanDates) {
// DatePeriod is better than anemic $fromDate and $toDate
}
}
final class LoanTrackerTests extends TestCase {
// Lots of maintained tests telling you how the system really works
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment