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

Yoast / wordpress-seo / ede6fd7c0b60c6046f5ca05162944c7a397d5d8b

20 Nov 2024 03:11PM UTC coverage: 54.21% (-2.9%) from 57.113%
ede6fd7c0b60c6046f5ca05162944c7a397d5d8b

Pull #21847

github

web-flow
Merge 428b097d7 into 74d330cc7
Pull Request #21847: Create API endpoints for SEO and readability scores

7593 of 13666 branches covered (55.56%)

Branch coverage included in aggregate %.

0 of 303 new or added lines in 24 files covered. (0.0%)

29764 of 55246 relevant lines covered (53.88%)

41542.83 hits per line

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

0.0
/src/dashboard/domain/scores/scores-list.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
namespace Yoast\WP\SEO\Dashboard\Domain\Scores;
4

5
/**
6
 * This class describes a list of scores.
7
 */
8
class Scores_List {
9

10
        /**
11
         * The scores.
12
         *
13
         * @var array<Scores_Interface>
14
         */
15
        private $scores = [];
16

17
        /**
18
         * Adds a score to the list.
19
         *
20
         * @param Scores_Interface $score The score to add.
21
         *
22
         * @return void
23
         */
NEW
24
        public function add( Scores_Interface $score ): void {
×
NEW
25
                $this->scores[] = $score;
×
26
        }
27

28
        /**
29
         * Parses the score list to the expected key value representation.
30
         *
31
         * @return array<array<string, string|int|array<string, string>>> The score list presented as the expected key value representation.
32
         */
NEW
33
        public function to_array(): array {
×
NEW
34
                $array = [];
×
NEW
35
                foreach ( $this->scores as $score ) {
×
NEW
36
                        $array[ $score->get_position() ] = [
×
NEW
37
                                'name'   => $score->get_name(),
×
NEW
38
                                'amount' => $score->get_amount(),
×
NEW
39
                                'links'  => ( $score->get_view_link() === null ) ? [] : [ 'view' => $score->get_view_link() ],
×
40
                        ];
41
                }
42

NEW
43
                \ksort( $array );
×
44

NEW
45
                return $array;
×
46
        }
47
}
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

© 2025 Coveralls, Inc