Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2.  
  3. class Student extends User implements StudentInterface
  4. {
  5.  
  6. public function setPassword($psswd)
  7. {
  8. if(is_string($psswd)) {
  9. $this->password = $psswd;
  10. }else {
  11. throw new Exception("Error Processing Request", 1);
  12. }
  13. }
  14.  
  15. public function auth($account, $psswd, AuthServices $auth) : boolean
  16. {
  17. if($psswd == ""){
  18. return false;
  19. }
  20. return true;
  21. }
  22.  
  23. }
  24.  
  25. class AuthServices {
  26.  
  27. public function auth(User $user)
  28. {
  29. if($user->getPassword() === $dbPassword){
  30. //do something...
  31. }
  32. }
  33.  
  34. }
  35.  
  36. /**
  37. * Whatever...
  38. */
  39.  
  40. interface StudentInterface
  41. {
  42. public function setPassword($psswd);
  43. }
  44.  
  45.  
  46. abstract class User {
  47.  
  48. public $id;
  49. protected $password;
  50.  
  51. abstract protected function auth($account, $psswd, AuthServices $auth) : boolean;
  52.  
  53. }
  54.  
  55.  
  56.  
  57. $user = new Student();
  58. $user->setPassword("hfudslafh");
  59.  
  60. print_r($user);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement