CallbackForm.php 799 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: artem
  5. * Date: 18.05.17
  6. * Time: 19:30
  7. */
  8. require_once('FormAbstract.php');
  9. class CallbackForm extends FormAbstract
  10. {
  11. public $name;
  12. public $phone;
  13. public function __construct(string $name, string $phone)
  14. {
  15. $this->name = $name;
  16. $this->phone = $phone;
  17. }
  18. public function validate(): bool
  19. {
  20. if (empty($this->name) || strlen($this->name) > 20 || strlen($this->name) < 2) {
  21. return false;
  22. }
  23. if (empty($this->phone) || strlen($this->phone) < 7 || strlen($this->phone) > 15) {
  24. return false;
  25. }
  26. return true;
  27. }
  28. public function send()
  29. {
  30. echo 'Name: ' . $this->name;
  31. echo '<br>';
  32. echo 'Phone: ' . $this->phone;
  33. }
  34. }