Taxonomy::get_labels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 47
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 28
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 47
rs 9.472
1
<?php declare(strict_types = 1);
2
3
namespace WPSteak\Services\Labels;
4
5
/** @codeCoverageIgnore */
6
trait Taxonomy {
7
8
	use Common;
9
10
	/**
11
	 * @param array<string> $defaults Defaults label.
12
	 * @return array<string>
13
	 */
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
			/* translators: %s label singular lower. */
20
			'update_item' => sprintf( __( 'Atualizar %s', 'wpsteak' ), $singular_lower ),
21
			'new_item_name' => sprintf(
22
				/* translators: %s label singular lower. */
23
				_n( 'Nome da nova %s', 'Nome do novo %s', $is_female, 'wpsteak' ),
24
				$singular_lower,
25
			),
26
			/* translators: %s label singular. */
27
			'parent_item' => sprintf( __( '%s pai', 'wpsteak' ), $singular ),
28
			/* translators: %s label singular. */
29
			'popular_items' => sprintf( __( '%s populares', 'wpsteak' ), $singular ),
30
			'separate_items_with_commas' => sprintf(
31
				/* translators: %s label plural lower. */
32
				_n( 'Separe as %s com virgulas', 'Separe os %s com virgulas', $is_female, 'wpsteak' ),
33
				$plural_lower,
34
			),
35
			/* translators: %s label singular lower. */
36
			'add_or_remove_items' => sprintf( __( 'Adicionar ou remover %s', 'wpsteak' ), $singular_lower ),
37
			'choose_from_most_used' => sprintf(
38
				/* translators: %s label plural lower. */
39
				_n( 'Escolher entre as %s mais usadas', 'Escolher entre os %s mais usados', $is_female, 'wpsteak' ),
40
				$plural_lower,
41
			),
42
			'back_to_items' => sprintf(
43
				/* translators: %s label singular lower. */
44
				_n( 'Voltar para as %s', 'Voltar para os %s', $is_female, 'wpsteak' ),
45
				$plural_lower,
46
			),
47
		];
48
49
		$labels = array_merge(
50
			$labels,
51
			$this->get_defaults(
52
				$singular,
53
				$singular_lower,
54
				$plural,
55
				$plural_lower,
56
				$is_female,
57
			),
58
		);
59
60
		return array_merge( $labels, $defaults );
61
	}
62
63
}
64