Example #1
0
 public static function instantiate($account, array $preferences = null)
 {
     $instance = new self();
     $instance->account()->associate($account);
     if ($preferences) {
         $instance->preferences = $preferences;
     }
     $instance->save();
     return $instance;
 }
Example #2
0
 public static function createWithFormat($parent, $spec)
 {
     if (is_string($spec) && strpos($spec, '@') !== false) {
         list($account, $host) = explode('@', $spec);
         $user = new self($parent);
         $user->account(trim($account, "`'"));
         $user->host(trim($host, "`'"));
         return $user;
     }
     throw new InvalidArgumentException('Invalid user spec format.');
 }