| @@ 78-85 (lines=8) @@ | ||
| 75 | * |
|
| 76 | * @return static |
|
| 77 | */ |
|
| 78 | public static function fromID($id) |
|
| 79 | { |
|
| 80 | if (! $term = get_term_by('id', (int) $id, static::TAXONOMY)) { |
|
| 81 | throw new TermNotFoundException("No term found with ID $id."); |
|
| 82 | } |
|
| 83 | ||
| 84 | return static::fromWpTerm($term); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Create a new instance from a slug. |
|
| @@ 94-101 (lines=8) @@ | ||
| 91 | * |
|
| 92 | * @return static |
|
| 93 | */ |
|
| 94 | public static function fromSlug($slug) |
|
| 95 | { |
|
| 96 | if (! $term = get_term_by('slug', $slug, static::TAXONOMY)) { |
|
| 97 | throw new TermNotFoundException("No term found with slug '$slug'."); |
|
| 98 | } |
|
| 99 | ||
| 100 | return static::fromWpTerm($term); |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Create a new instance from an array of attributes. |
|