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