Advertisement
fruffl

Class Guid

Sep 16th, 2011
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?PHP
  2.             class Guid extends Object implements Guid_Interface
  3.             {
  4.                     public function __construct()
  5.                     {
  6.                         try{
  7.                            
  8.                             try{parent::__construct(NULL);}
  9.                             catch(DatatypeExpectedException $e){throw new DatatypeExpectedException($e->getCode());}
  10.                             catch(ArgumentNullException $e){throw new ArgumentNullException($e->getCode());}
  11.                            
  12.                             $uid = new String;
  13.                             $int = new Integer;
  14.                             $cat = new String;
  15.                            
  16.                             $uid->set((string) md5($this->getHashCode()->get()))
  17.                                 ->insert($int->set(8), $cat->set('-'))
  18.                                 ->insert($int->set(13), $cat)
  19.                                 ->insert($int->set(18), $cat)
  20.                                 ->insert($int->set(23), $cat);
  21.                                
  22.                             $this->set($uid->get());
  23.                             $this->finalize()->lock();
  24.                            
  25.                         }catch(SystemException $e){throw new ObjectHandlerException(ObjectHandlerException::ERROR_CAN_NOT_CREATE, $e);}
  26.        
  27.                     }
  28.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement