@@ 66-73 (lines=8) @@ | ||
63 | * |
|
64 | * @return static |
|
65 | */ |
|
66 | public static function fromID($id) |
|
67 | { |
|
68 | if (! $user = get_user_by('id', $id)) { |
|
69 | throw new UserNotFoundException("No user found with ID $id"); |
|
70 | } |
|
71 | ||
72 | return new static($user); |
|
73 | } |
|
74 | ||
75 | /** |
|
76 | * Create a new instance from the username. |
|
@@ 102-109 (lines=8) @@ | ||
99 | * |
|
100 | * @return static |
|
101 | */ |
|
102 | public static function fromEmail($email) |
|
103 | { |
|
104 | if (! $user = get_user_by('email', $email)) { |
|
105 | throw new UserNotFoundException("No user found with email address: $email"); |
|
106 | } |
|
107 | ||
108 | return new static($user); |
|
109 | } |
|
110 | ||
111 | /** |
|
112 | * Create a new instance from the user's slug. |
|
@@ 120-127 (lines=8) @@ | ||
117 | * |
|
118 | * @return static |
|
119 | */ |
|
120 | public static function fromSlug($slug) |
|
121 | { |
|
122 | if (! $user = get_user_by('slug', $slug)) { |
|
123 | throw new UserNotFoundException("No user found with slug: $slug"); |
|
124 | } |
|
125 | ||
126 | return new static($user); |
|
127 | } |
|
128 | ||
129 | /** |
|
130 | * Create a new instance using the currently authenticated user. |