| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php declare(strict_types = 1); |
||
| 14 | public function get_labels( string $singular, string $plural, int $is_female = 0, array $defaults = [] ): array { |
||
| 15 | $singular_lower = strtolower( $singular ); |
||
| 16 | $plural_lower = strtolower( $plural ); |
||
| 17 | |||
| 18 | $labels = [ |
||
| 19 | 'add_new' => _n( 'Adicionar nova', 'Adicionar novo', $is_female, 'wpsteak' ), |
||
| 20 | /* translators: %s label singular female lower; %s label singular male lower; */ |
||
| 21 | 'new_item' => sprintf( _n( 'Nova %s', 'Novo %s', $is_female, 'wpsteak' ), $singular_lower ), |
||
| 22 | /* translators: %s label plural lower. */ |
||
| 23 | 'view_items' => sprintf( __( 'Ver %s', 'wpsteak' ), $plural_lower ), |
||
| 24 | 'not_found_in_trash' => sprintf( |
||
| 25 | /* translators: %s label singular lower. */ |
||
| 26 | _n( 'Nenhuma %s encontrada na Lixeira.', 'Nenhum %s encontrado na Lixeira.', $is_female, 'wpsteak' ), |
||
| 27 | $singular_lower, |
||
| 28 | ), |
||
| 29 | /* translators: %s label plural lower. */ |
||
| 30 | 'archives' => sprintf( __( 'Arquivos de %s', 'wpsteak' ), $plural_lower ), |
||
| 31 | /* translators: %s label plural lower. */ |
||
| 32 | 'attributes' => sprintf( __( 'Atributos de %s', 'wpsteak' ), $plural_lower ), |
||
| 33 | 'insert_into_item' => sprintf( |
||
| 34 | /* translators: %s label singular lower. */ |
||
| 35 | _n( 'Inserir na %s', 'Inserir no %s', $is_female, 'wpsteak' ), |
||
| 36 | $singular_lower, |
||
| 37 | ), |
||
| 38 | 'uploaded_to_this_item' => sprintf( |
||
| 39 | /* translators: %s label singular lower. */ |
||
| 40 | _n( 'Carregado para esta %s', 'Carregado para este %s', $is_female, 'wpsteak' ), |
||
| 41 | $singular_lower, |
||
| 42 | ), |
||
| 43 | 'featured_image' => __( 'Imagem destacada', 'wpsteak' ), |
||
| 44 | 'set_featured_image' => __( 'Definir imagem destacada', 'wpsteak' ), |
||
| 45 | 'remove_featured_image' => __( 'Remover imagem destacada', 'wpsteak' ), |
||
| 46 | 'use_featured_image' => __( 'Usar como imagem destacada', 'wpsteak' ), |
||
| 47 | /* translators: %s label plural lower. */ |
||
| 48 | 'filter_items_list' => sprintf( __( 'Filtrar lista de %s', 'wpsteak' ), $plural_lower ), |
||
| 49 | /* translators: %s label plural lower. */ |
||
| 50 | 'items_list_navigation' => sprintf( __( 'Navegação da lista de %s', 'wpsteak' ), $plural_lower ), |
||
| 51 | /* translators: %s label plural lower. */ |
||
| 52 | 'items_list' => sprintf( __( 'Lista de %s', 'wpsteak' ), $plural_lower ), |
||
| 53 | 'name_admin_bar' => $singular, |
||
| 54 | ]; |
||
| 55 | |||
| 56 | $labels = array_merge( |
||
| 57 | $labels, |
||
| 58 | $this->get_defaults( |
||
| 59 | $singular, |
||
| 60 | $singular_lower, |
||
| 61 | $plural, |
||
| 62 | $plural_lower, |
||
| 63 | $is_female, |
||
| 64 | ), |
||
| 65 | ); |
||
| 66 | |||
| 67 | return array_merge( $labels, $defaults ); |
||
| 68 | } |
||
| 71 |