PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.3
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 / task-list / domain / tasks / abstract-task.php

abstract-task.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at src/task-list/domain/tasks/abstract-task.php

131 lines 2.6 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\Task_List\Domain\Tasks;
5
6 use Yoast\WP\SEO\Task_List\Domain\Components\Call_To_Action_Entry;
7
8 /**
9 * Abstract class for a task.
10 */
11 abstract class Abstract_Task implements Task_Interface {
12
13 /**
14 * The ID of the task.
15 *
16 * @var string
17 */
18 protected $id;
19
20 /**
21 * The priority of the task.
22 *
23 * @var string
24 */
25 protected $priority;
26
27 /**
28 * The duration of the task.
29 *
30 * @var int
31 */
32 protected $duration;
33
34 /**
35 * Whether the task is completed. Can be used for caching the completed status if the calculation is expensive.
36 *
37 * @var bool|null
38 */
39 protected $is_completed = null;
40
41 /**
42 * The enhanced call to action.
43 *
44 * @var Call_To_Action_Entry
45 */
46 private $enhanced_call_to_action;
47
48 /**
49 * Returns the task ID.
50 *
51 * @return string
52 */
53 public function get_id(): string {
54 return $this->id;
55 }
56
57 /**
58 * Returns the task's priority.
59 *
60 * @return string
61 */
62 public function get_priority(): string {
63 return $this->priority;
64 }
65
66 /**
67 * Returns the task's duration.
68 *
69 * @return int
70 */
71 public function get_duration(): int {
72 return $this->duration;
73 }
74
75 /**
76 * Returns the task's badge.
77 *
78 * @return string|null
79 */
80 public function get_badge(): ?string {
81 return null;
82 }
83
84 /**
85 * Sets the enhanced call to action.
86 *
87 * @param Call_To_Action_Entry $enhanced_call_to_action The enhanced call to action.
88 *
89 * @return void
90 */
91 public function set_enhanced_call_to_action( ?Call_To_Action_Entry $enhanced_call_to_action ): void {
92 $this->enhanced_call_to_action = $enhanced_call_to_action;
93 }
94
95 /**
96 * Returns the enhanced call to action.
97 *
98 * @return Call_To_Action_Entry|null
99 */
100 public function get_enhanced_call_to_action(): ?Call_To_Action_Entry {
101 return $this->enhanced_call_to_action;
102 }
103
104 /**
105 * Returns an array representation of the task data.
106 *
107 * @return array<string, string|bool> Returns in an array format.
108 */
109 public function to_array(): array {
110 $data = [
111 'id' => $this->get_id(),
112 'duration' => $this->get_duration(),
113 'priority' => $this->get_priority(),
114 'badge' => $this->get_badge(),
115 'isCompleted' => $this->get_is_completed(),
116 'callToAction' => ( $this->get_enhanced_call_to_action() !== null ) ? $this->get_enhanced_call_to_action()->to_array() : null,
117 ];
118
119 return \array_merge( $data, $this->get_copy_set()->to_array() );
120 }
121
122 /**
123 * Returns whether the task is valid.
124 *
125 * @return bool
126 */
127 public function is_valid(): bool {
128 return true;
129 }
130 }
131