SHARE
TWEET

Untitled

a guest Oct 16th, 2012 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top