• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 55dec9a111eaff1b7fe75cefc941ff84009561d0

16 Feb 2026 08:03AM UTC coverage: 53.608% (+0.6%) from 52.986%
55dec9a111eaff1b7fe75cefc941ff84009561d0

Pull #22972

github

leonidasmi
Merge trunk
Pull Request #22972: Add tasks about the SEO and readability of recent posts

8934 of 16506 branches covered (54.13%)

Branch coverage included in aggregate %.

391 of 600 new or added lines in 40 files covered. (65.17%)

1 existing line in 1 file now uncovered.

33402 of 62467 relevant lines covered (53.47%)

47894.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.86
/src/task-list/domain/tasks/parent-task-trait.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
namespace Yoast\WP\SEO\Task_List\Domain\Tasks;
4

5
/**
6
 * Trait for parent task functionality.
7
 * Provides the implementation for Parent_Task_Interface methods.
8
 */
9
trait Parent_Task_Trait {
10

11
        /**
12
         * The child tasks associated with the task.
13
         *
14
         * @var Child_Task_Interface[]
15
         */
16
        protected $child_tasks = [];
17

18
        /**
19
         * Returns the child tasks associated with the task.
20
         *
21
         * @return Child_Task_Interface[]
22
         */
NEW
23
        public function get_child_tasks(): array {
×
NEW
24
                return $this->child_tasks;
×
25
        }
26

27
        /**
28
         * Sets the child tasks associated with the task.
29
         *
30
         * @param Child_Task_Interface[] $child_tasks The child tasks to set.
31
         *
32
         * @return void
33
         */
NEW
34
        public function set_child_tasks( array $child_tasks ): void {
×
NEW
35
                $this->child_tasks = $child_tasks;
×
36
        }
37

38
        /**
39
         * Returns whether this task is completed.
40
         * The parent task is completed when all child tasks are completed.
41
         *
42
         * @return bool Whether this task is completed.
43
         */
44
        public function get_is_completed(): bool {
12✔
45
                $child_tasks = $this->child_tasks;
12✔
46

47
                foreach ( $child_tasks as $task ) {
12✔
48
                        if ( ! $task->get_is_completed() ) {
8✔
49
                                return false;
4✔
50
                        }
51
                }
52

53
                return true;
8✔
54
        }
55

56
        /**
57
         * Generates and sets the child tasks.
58
         *
59
         * @return Child_Task_Interface[] The generated child tasks.
60
         */
NEW
61
        public function generate_child_tasks(): array {
×
NEW
62
                $this->child_tasks = $this->populate_child_tasks();
×
63

NEW
64
                return $this->child_tasks;
×
65
        }
66

67
        /**
68
         * Returns the task's duration, calculated by summing durations of incomplete child tasks.
69
         *
70
         * @return int The total duration in minutes.
71
         */
72
        public function get_duration(): int {
20✔
73
                $child_tasks = $this->get_child_tasks();
20✔
74

75
                if ( empty( $child_tasks ) ) {
20✔
76
                        return 0;
6✔
77
                }
78

79
                $total_duration = 0;
14✔
80
                foreach ( $child_tasks as $child_task ) {
14✔
81
                        if ( ! $child_task->get_is_completed() ) {
14✔
82
                                $total_duration += $child_task->get_duration();
8✔
83
                        }
84
                }
85

86
                return $total_duration;
14✔
87
        }
88

89
        /**
90
         * Returns an array representation of the task data.
91
         * When used in a class extending Abstract_Task, this will call the parent's to_array()
92
         * and add the parent task flag.
93
         *
94
         * @return array<string, string|bool> Returns in an array format.
95
         */
96
        public function to_array(): array {
12✔
97
                $data = [];
12✔
98

99
                $parent_class = \get_parent_class( $this );
12✔
100
                if ( $parent_class !== false && \method_exists( $parent_class, 'to_array' ) ) {
12✔
101
                        $data = parent::to_array();
12✔
102
                }
103

104
                // @TODO: Consider whether this 'parentTask' flag is still necessary, as the frontend doesn't use it.
105
                $data['parentTask'] = true;
12✔
106

107
                return $data;
12✔
108
        }
109
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc