Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User
- {
- private $name;
- public function getName()
- {
- return $this->name;
- }
- public function setName($newName)
- {
- if($this->validateName($newName))
- $this->name = $newName;
- else
- throw new \Exception('Invalid name');
- }
- private function validateName($name)
- {
- return preg_match('#[a-z]*#iu', $name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement