| @@ 90-97 (lines=8) @@ | ||
| 87 | * |
|
| 88 | * @return static |
|
| 89 | */ |
|
| 90 | public static function fromID($id) |
|
| 91 | { |
|
| 92 | if (! $term = get_term_by('id', (int) $id, static::TAXONOMY)) { |
|
| 93 | throw new TermNotFoundException("No term found with ID $id."); |
|
| 94 | } |
|
| 95 | ||
| 96 | return new static($term); |
|
| 97 | } |
|
| 98 | ||
| 99 | /** |
|
| 100 | * Create a new instance from a slug. |
|
| @@ 108-115 (lines=8) @@ | ||
| 105 | * |
|
| 106 | * @return static |
|
| 107 | */ |
|
| 108 | public static function fromSlug($slug) |
|
| 109 | { |
|
| 110 | if (! $term = get_term_by('slug', $slug, static::TAXONOMY)) { |
|
| 111 | throw new TermNotFoundException("No term found with slug '$slug'."); |
|
| 112 | } |
|
| 113 | ||
| 114 | return new static($term); |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Check if this term exists in the database. |
|