| Conditions | 3 | 
| Paths | 4 | 
| Total Lines | 17 | 
| Code Lines | 10 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
| 1 | <?php  | 
            ||
| 10 | public function execute()  | 
            ||
| 11 |     { | 
            ||
| 12 | $taxonomy = $this->model->taxonomy()->id;  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 13 | |||
| 14 |         if ($this->model->id) { | 
            ||
| 15 | $ids = wp_update_term($this->model->id, $taxonomy, $this->model->term->to_array());  | 
            ||
| 16 |         } else { | 
            ||
| 17 | $ids = wp_insert_term($this->model->name, $taxonomy, $this->model->term->to_array());  | 
            ||
| 18 | }  | 
            ||
| 19 | |||
| 20 |         if (is_wp_error($ids)) { | 
            ||
| 21 | throw new WP_ErrorException($ids);  | 
            ||
| 22 | }  | 
            ||
| 23 | |||
| 24 | $this->model->setId($ids['term_id']);  | 
            ||
| 25 | $this->model->refresh();  | 
            ||
| 26 | }  | 
            ||
| 27 | }  | 
            ||
| 28 | 
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: