Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. class Rating {
  6. private $value;
  7.  
  8. public function __construct(float $value) {
  9. if ($value < 0 || $value > 5) {
  10. throw new \InvalidArgumentException('A rating should always be a number between 0 and 5!');
  11. }
  12.  
  13. $this->value = $value;
  14. }
  15.  
  16. public function getValue() : float {
  17. return $this->value;
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement