Skip to content

Instantly share code, notes, and snippets.

@yourwebmaker
Created February 21, 2022 14:09
Show Gist options
  • Save yourwebmaker/2bb5bcf133b210fb5a386230582b2e6c to your computer and use it in GitHub Desktop.
Save yourwebmaker/2bb5bcf133b210fb5a386230582b2e6c to your computer and use it in GitHub Desktop.
<?php
class Book
{
private $rates = [];
public function rate(string $userId, int $rate) : void
{
if (isset($this->rates[$userid])) {
throw new AlreadyRatedThisBook();
}
$this->rate[$userId] = $rate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment