PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / dashboard / domain / taxonomies / taxonomy.php

taxonomy.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/dashboard/domain/taxonomies/taxonomy.php

73 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4 namespace Yoast\WP\SEO\Dashboard\Domain\Taxonomies;
5
6 /**
7 * This class describes a Taxonomy.
8 */
9 class Taxonomy {
10
11 /**
12 * The name of the taxonomy.
13 *
14 * @var string
15 */
16 private $name;
17
18 /**
19 * The label of the taxonomy.
20 *
21 * @var string
22 */
23 private $label;
24
25 /**
26 * The REST URL of the taxonomy.
27 *
28 * @var string
29 */
30 private $rest_url;
31
32 /**
33 * The constructor.
34 *
35 * @param string $name The name of the taxonomy.
36 * @param string $label The label of the taxonomy.
37 * @param string $rest_url The REST URL of the taxonomy.
38 */
39 public function __construct(
40 string $name,
41 string $label,
42 string $rest_url
43 ) {
44 $this->name = $name;
45 $this->label = $label;
46 $this->rest_url = $rest_url;
47 }
48
49 /**
50 * Returns the name of the taxonomy.
51 *
52 * @return string The name of the taxonomy.
53 */
54 public function get_name(): string {
55 return $this->name;
56 }
57
58 /**
59 * Parses the taxonomy to the expected key value representation.
60 *
61 * @return array<string, array<string, string>> The taxonomy presented as the expected key value representation.
62 */
63 public function to_array(): array {
64 return [
65 'name' => $this->name,
66 'label' => $this->label,
67 'links' => [
68 'search' => $this->rest_url,
69 ],
70 ];
71 }
72 }
73