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

Yoast / wordpress-seo / 5730cb79f488a5fed855d114b14f03b5a8cbf443

14 Jan 2025 01:34PM UTC coverage: 51.158%. First build
5730cb79f488a5fed855d114b14f03b5a8cbf443

Pull #21965

github

web-flow
Merge 8afb9bb5d into 9c6695675
Pull Request #21965: First run at a setup

0 of 103 new or added lines in 8 files covered. (0.0%)

16657 of 32560 relevant lines covered (51.16%)

3.96 hits per line

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

0.0
/src/dashboard/infrastructure/search-console/site-kit-search-console-adapter.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
3
// phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded
4
namespace Yoast\WP\SEO\Dashboard\Infrastructure\Search_Console;
5

6
use Google\Site_Kit\Core\Modules\Module;
7
use Google\Site_Kit\Core\Modules\Modules;
8
use Google\Site_Kit\Modules\Search_Console;
9
use Google\Site_Kit\Plugin;
10
use Google\Site_Kit_Dependencies\Google\Service\SearchConsole\ApiDataRow;
11
use WP_Error;
12
use Yoast\WP\SEO\Dashboard\Domain\Search_Rankings\Request_Parameters;
13

14
/**
15
 * The site API adapter to make calls via the Site_Kit plugin.
16
 */
17
class Site_Kit_Search_Console_Adapter {
18

19
        /**
20
         * The search console module class from Site kit.
21
         *
22
         * @var Module
23
         */
24
        private static $search_console_module;
25

26
        /**
27
         * The register method that sets the instance in the adapter.
28
         *
29
         * @return void
30
         */
NEW
31
        public function __construct() {
×
NEW
32
                if ( \class_exists( 'Google\Site_Kit\Plugin' ) ) {
×
NEW
33
                        $site_kit_plugin             = Plugin::instance();
×
NEW
34
                        $modules                     = new Modules( $site_kit_plugin->context() );
×
NEW
35
                        self::$search_console_module = $modules->get_module( Search_Console::MODULE_SLUG );
×
36
                }
37
        }
38

39
        /**
40
         * The wrapper method to add our parameters to a Site Kit API request.
41
         *
42
         * @param Request_Parameters $parameters The parameters.
43
         *
44
         * @return ApiDataRow[]|WP_Error Data on success, or WP_Error on failure.
45
         */
NEW
46
        public function get_data( Request_Parameters $parameters ) {
×
47
                $api_parameters = [
NEW
48
                        'slug'       => 'search-console',
×
NEW
49
                        'datapoint'  => 'searchanalytics',
×
NEW
50
                        'startDate'  => $parameters->get_start_date(),
×
NEW
51
                        'endDate'    => $parameters->get_end_date(),
×
NEW
52
                        'limit'      => $parameters->get_limit(),
×
NEW
53
                        'dimensions' => $parameters->get_dimensions(),
×
54
                ];
55

NEW
56
                return self::$search_console_module->get_data( 'searchanalytics', $api_parameters );
×
57
        }
58
}
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