Skip to content

Commit cb42aff

Browse files
committed
Update the class constants to use new names
1 parent 8c6bfac commit cb42aff

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

plugins/image-prioritizer/helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ function image_prioritizer_filter_rest_request_before_callbacks( $response, arra
297297

298298
// Check for class existence and use constant or class method calls accordingly.
299299
$route_endpoint = class_exists( 'OD_REST_URL_Metrics_Store_Endpoint' )
300-
? OD_REST_URL_Metrics_Store_Endpoint::REST_API_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::REST_API_ROUTE
300+
? OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE
301301
: OD_REST_API_NAMESPACE . OD_URL_METRICS_ROUTE; // @phpstan-ignore constant.deprecated, constant.deprecated (To be replaced with class method calls in subsequent release.)
302302

303303
if (

plugins/image-prioritizer/tests/test-helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ public function data_provider_to_test_image_prioritizer_filter_rest_request_befo
727727
};
728728

729729
$create_request = static function ( array $url_metric_data ): WP_REST_Request {
730-
$request = new WP_REST_Request( 'POST', '/' . OD_REST_URL_Metrics_Store_Endpoint::REST_API_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::REST_API_ROUTE );
730+
$request = new WP_REST_Request( 'POST', '/' . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE );
731731
$request->set_header( 'content-type', 'application/json' );
732732
$request->set_body( wp_json_encode( $url_metric_data ) );
733733
return $request;

plugins/optimization-detective/deprecated.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @since 0.1.0
1919
* @access private
20-
* @deprecated n.e.x.t This constant should not be used, instead use OD_REST_URL_Metrics_Store_Endpoint::REST_API_NAMESPACE method.
20+
* @deprecated n.e.x.t This constant should not be used, instead use OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE method.
2121
* @var string
2222
*/
2323
const OD_REST_API_NAMESPACE = 'optimization-detective/v1';
@@ -32,7 +32,7 @@
3232
* @since 0.1.0
3333
* @access private
3434
* @link https://google.aip.dev/136
35-
* @deprecated n.e.x.t This constant should not be used, instead use OD_REST_URL_Metrics_Store_Endpoint::REST_API_ROUTE method.
35+
* @deprecated n.e.x.t This constant should not be used, instead use OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE method.
3636
* @var string
3737
*/
3838
const OD_URL_METRICS_ROUTE = '/url-metrics:store';

plugins/optimization-detective/detection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function od_get_detection_script( string $slug, OD_URL_Metric_Group_Collection $
121121
'maxViewportAspectRatio' => od_get_maximum_viewport_aspect_ratio(),
122122
'isDebug' => WP_DEBUG,
123123
'extensionModuleUrls' => $extension_module_urls,
124-
'restApiEndpoint' => rest_url( OD_REST_URL_Metrics_Store_Endpoint::REST_API_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::REST_API_ROUTE ),
124+
'restApiEndpoint' => rest_url( OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE ),
125125
'currentETag' => $current_etag,
126126
'currentUrl' => $current_url,
127127
'urlMetricSlug' => $slug,
@@ -169,8 +169,8 @@ function od_register_rest_url_metric_store_endpoint(): void {
169169
$endpoint_controller = new OD_REST_URL_Metrics_Store_Endpoint();
170170

171171
register_rest_route(
172-
$endpoint_controller::REST_API_NAMESPACE,
173-
$endpoint_controller::REST_API_ROUTE,
172+
$endpoint_controller::ROUTE_NAMESPACE,
173+
$endpoint_controller::ROUTE_BASE,
174174
$endpoint_controller->get_registration_args()
175175
);
176176
}

plugins/optimization-detective/site-health.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function od_compose_site_health_result( $response ): array {
9191
sprintf(
9292
/* translators: %s is the REST API endpoint */
9393
__( 'To collect URL Metrics from visitors the REST API must be available to unauthenticated users. Specifically, visitors must be able to perform a <code>POST</code> request to the <code>%s</code> endpoint.', 'optimization-detective' ),
94-
'/' . OD_REST_URL_Metrics_Store_Endpoint::REST_API_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::REST_API_ROUTE
94+
'/' . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE
9595
),
9696
array( 'code' => array() )
9797
) . '</p>';
@@ -192,7 +192,7 @@ function od_get_rest_api_health_check_response( bool $use_cached ) {
192192
if ( false !== $response ) {
193193
return $response;
194194
}
195-
$rest_url = get_rest_url( null, OD_REST_URL_Metrics_Store_Endpoint::REST_API_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::REST_API_ROUTE );
195+
$rest_url = get_rest_url( null, OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE );
196196
$response = wp_remote_post(
197197
$rest_url,
198198
array(

plugins/optimization-detective/storage/class-od-rest-url-metrics-store-endpoint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class OD_REST_URL_Metrics_Store_Endpoint {
2626
* @since n.e.x.t
2727
* @var string
2828
*/
29-
const REST_API_NAMESPACE = 'optimization-detective/v1';
29+
const ROUTE_NAMESPACE = 'optimization-detective/v1';
3030

3131
/**
3232
* Route for storing a URL Metric.
@@ -39,7 +39,7 @@ final class OD_REST_URL_Metrics_Store_Endpoint {
3939
* @link https://google.aip.dev/136
4040
* @var string
4141
*/
42-
const REST_API_ROUTE = '/url-metrics:store';
42+
const ROUTE_BASE = '/url-metrics:store';
4343

4444
/**
4545
* Gets the arguments for registering the endpoint.

plugins/optimization-detective/tests/storage/test-class-od-rest-url-metrics-store-endpoint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Test_OD_REST_URL_Metrics_Store_Endpoint extends WP_UnitTestCase {
1919
* @return string Route.
2020
*/
2121
private function get_route(): string {
22-
return '/' . OD_REST_URL_Metrics_Store_Endpoint::REST_API_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::REST_API_ROUTE;
22+
return '/' . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE;
2323
}
2424

2525
/**

plugins/optimization-detective/tests/test-detection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function test_od_get_detection_script_returns_script( Closure $set_up, ar
234234
public function od_register_rest_url_metric_store_endpoint(): void {
235235

236236
$routes = rest_get_server()->get_routes();
237-
$this->assertArrayHasKey( '/' . OD_REST_URL_Metrics_Store_Endpoint::REST_API_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::REST_API_ROUTE, $routes );
237+
$this->assertArrayHasKey( '/' . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE, $routes );
238238
}
239239

240240
/**

plugins/optimization-detective/tests/test-site-health.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ protected function filter_rest_api_response( $mocked_response ): object {
420420
add_filter(
421421
'pre_http_request',
422422
static function ( $pre, array $args, string $url ) use ( $mocked_response, $observer ) {
423-
if ( rest_url( OD_REST_URL_Metrics_Store_Endpoint::REST_API_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::REST_API_ROUTE ) === $url ) {
423+
if ( rest_url( OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE ) === $url ) {
424424
$observer->counter++;
425425
return $mocked_response;
426426
}

0 commit comments

Comments
 (0)