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