| @@ 49-56 (lines=8) @@ | ||
| 46 | * |
|
| 47 | * @return static |
|
| 48 | */ |
|
| 49 | public static function fromID($id) |
|
| 50 | { |
|
| 51 | if (! $user = get_user_by('id', $id)) { |
|
| 52 | throw new UserNotFoundException("No user found with ID $id"); |
|
| 53 | } |
|
| 54 | ||
| 55 | return new static($user); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Create a new instance from the username. |
|
| @@ 85-92 (lines=8) @@ | ||
| 82 | * |
|
| 83 | * @return static |
|
| 84 | */ |
|
| 85 | public static function fromEmail($email) |
|
| 86 | { |
|
| 87 | if (! $user = get_user_by('email', $email)) { |
|
| 88 | throw new UserNotFoundException("No user found with email address: $email"); |
|
| 89 | } |
|
| 90 | ||
| 91 | return new static($user); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * Create a new instance from the user's slug. |
|
| @@ 103-110 (lines=8) @@ | ||
| 100 | * |
|
| 101 | * @return static |
|
| 102 | */ |
|
| 103 | public static function fromSlug($slug) |
|
| 104 | { |
|
| 105 | if (! $user = get_user_by('slug', $slug)) { |
|
| 106 | throw new UserNotFoundException("No user found with slug: $slug"); |
|
| 107 | } |
|
| 108 | ||
| 109 | return new static($user); |
|
| 110 | } |
|
| 111 | ||
| 112 | /** |
|
| 113 | * Create a new instance using the currently authenticated user. |
|