Pharmacy.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Model;
  3. class Pharmacy extends ModelAbstract
  4. {
  5. public $id;
  6. public $name;
  7. public $city;
  8. public $street;
  9. public $house;
  10. public $phone;
  11. public function __construct(string $name, string $city, string $street, string $house, string $phone, int $id = null)
  12. {
  13. $this->name = $name;
  14. $this->city = $city;
  15. $this->street = $street;
  16. $this->house = $house;
  17. $this->phone = $phone;
  18. $this->id = $id;
  19. }
  20. public function validate(): bool
  21. {
  22. if (iconv_strlen($this->name) > 50 || iconv_strlen($this->name) < 2) {
  23. return false;
  24. }
  25. if (iconv_strlen($this->city) > 50 || iconv_strlen($this->city) < 2) {
  26. return false;
  27. }
  28. if (iconv_strlen($this->street) > 50 || iconv_strlen($this->street) < 2) {
  29. return false;
  30. }
  31. if (iconv_strlen($this->house) > 50 || iconv_strlen($this->house) < 1) {
  32. return false;
  33. }
  34. if (iconv_strlen($this->phone) > 15 || iconv_strlen($this->phone) < 7) {
  35. return false;
  36. }
  37. return true;
  38. }
  39. }