Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User
- {
- protected $name;
- protected $surname;
- protected $password;
- public function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- public function setSurname($surname)
- {
- $this->surname = $surname;
- return $this;
- }
- public function setPassword($password)
- {
- if (!$password) {
- throw new InvalidArgumentException("Password shouldn't be empty");
- }
- $this->password = $password;
- return $this;
- }
- }
- $user = new User;
- $user->setName('John')->setSurname('Doe')->setPassword('root');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement