Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update APIClient.php #6827

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 34 additions & 32 deletions inc/Engine/Common/JobManager/APIHandler/APIClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,37 +108,39 @@
* @return array
*/
public function get_queue_job_status( $job_id, $queue_name, $is_home = false ) {
$args = [
'body' => [
'id' => $job_id,
'force_queue' => $queue_name,
'is_home' => $is_home,
],
'timeout' => 5,
];

if ( ! $this->handle_get( $args ) ) {
return [
'code' => $this->response_code,
'message' => $this->error_message,
];
}

$default = [
'code' => 400,
'status' => 'failed',
'message' => 'No message. Defaulted in get_queue_job_status',
'contents' => [
'success' => false,
'shakedCSS' => '',
'above_the_fold_result' => [
'lcp' => [],
'images_above_fold' => [],
],
],
];

$result = json_decode( $this->response_body, true );
return (array) wp_parse_args( ( $result && $result['returnvalue'] ) ? (array) $result['returnvalue'] : [], $default );
$args = [

Check notice on line 111 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L111

Line indented incorrectly; expected at least 2 tabs, found 1
'body' => [

Check notice on line 112 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L112

Tabs must be used to indent lines; spaces are not allowed
'id' => $job_id,
'force_queue' => $queue_name,

Check notice on line 114 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L114

Tabs must be used to indent lines; spaces are not allowed
'is_home' => $is_home,

Check notice on line 115 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L115

Tabs must be used to indent lines; spaces are not allowed
],

Check notice on line 116 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L116

Tabs must be used to indent lines; spaces are not allowed
'timeout' => 5,
];

Check notice on line 118 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L118

Line indented incorrectly; expected at least 2 tabs, found 1

Check notice on line 118 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L118

Tabs must be used to indent lines; spaces are not allowed

if ( ! $this->handle_get( $args ) ) {

Check notice on line 120 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L120

Tabs must be used to indent lines; spaces are not allowed
return [

Check notice on line 121 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L121

Line indented incorrectly; expected at least 3 tabs, found 2

Check notice on line 121 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L121

Tabs must be used to indent lines; spaces are not allowed
'code' => $this->response_code,

Check notice on line 122 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L122

Tabs must be used to indent lines; spaces are not allowed
'message' => $this->error_message,

Check notice on line 123 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L123

Tabs must be used to indent lines; spaces are not allowed
];
}

Check notice on line 125 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L125

Line indented incorrectly; expected 2 tabs, found 1

$default = [

Check notice on line 127 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L127

Tabs must be used to indent lines; spaces are not allowed
'code' => 400,

Check notice on line 128 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L128

Tabs must be used to indent lines; spaces are not allowed
'status' => 'failed',

Check notice on line 129 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L129

Array double arrow not aligned correctly; expected 3 space(s) between "'status'" and double arrow, but found 2.
'message' => 'No message. Defaulted in get_queue_job_status',

Check notice on line 130 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L130

Array double arrow not aligned correctly; expected 2 space(s) between "'message'" and double arrow, but found 1.

Check notice on line 130 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L130

Tabs must be used to indent lines; spaces are not allowed
'contents' => [
'success' => false,
'shakedCSS' => '',

Check notice on line 133 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L133

Tabs must be used to indent lines; spaces are not allowed
'above_the_fold_result' => [
'lcp' => [],

Check notice on line 135 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L135

Array double arrow not aligned correctly; expected 15 space(s) between "'lcp'" and double arrow, but found 16.
'images_above_fold' => [],
],
],
];

$result = json_decode( $this->response_body, true );

Check notice on line 141 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L141

Tabs must be used to indent lines; spaces are not allowed

Check notice on line 142 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L142

Whitespace found at end of line
// Corrected part: Check if $result is an array and has the 'returnvalue' key

Check notice on line 143 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L143

Tabs must be used to indent lines; spaces are not allowed
return (array) wp_parse_args( ( is_array($result) && isset( $result['returnvalue'] ) ) ? (array) $result['returnvalue'] : [], $default );

Check notice on line 144 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L144

Expected 1 spaces after opening parenthesis; 0 found

Check notice on line 144 in inc/Engine/Common/JobManager/APIHandler/APIClient.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Common/JobManager/APIHandler/APIClient.php#L144

Whitespace found at end of line
}
}