Advertisement
Guest User

Untitled

a guest
Oct 16th, 2012
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. class User
  2. {
  3.     private $name;
  4.    
  5.     public function getName()
  6.     {
  7.         return $this->name;
  8.     }
  9.    
  10.     public function setName($newName)
  11.     {
  12.         if($this->validateName($newName))
  13.             $this->name = $newName;
  14.         else
  15.             throw new \Exception('Invalid name');
  16.     }
  17.    
  18.     private function validateName($name)
  19.     {
  20.         return preg_match('#[a-z]*#iu', $name);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement