Advertisement
Guest User

Untitled

a guest
Feb 24th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2.  
  3. class User
  4. {
  5. protected $name;
  6. protected $surname;
  7. protected $password;
  8.  
  9. public function setName($name)
  10. {
  11. $this->name = $name;
  12. return $this;
  13. }
  14.  
  15. public function setSurname($surname)
  16. {
  17. $this->surname = $surname;
  18. return $this;
  19. }
  20.  
  21. public function setPassword($password)
  22. {
  23. if (!$password) {
  24. throw new InvalidArgumentException("Password shouldn't be empty");
  25. }
  26. $this->password = $password;
  27. return $this;
  28. }
  29. }
  30.  
  31. $user = new User;
  32. $user->setName('John')->setSurname('Doe')->setPassword('root');
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement