Skip to content

Commit

Permalink
lint updates
Browse files Browse the repository at this point in the history
  • Loading branch information
circlecube committed Nov 6, 2024
1 parent 42284c8 commit c38bc54
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions includes/HiiveConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class HiiveConnection implements SubscriberInterface {
private $throttled;

/**
* The throttle
*
* @var bool
*/
protected $throttle;
Expand Down Expand Up @@ -124,6 +126,10 @@ public static function is_connected(): bool {
*
* @used-by Data::init()
* @used-by HiiveConnection::reconnect()
*
* @param string $path the path
* @param $authorization the authorization
* @return Boolean success
*/
public function connect( string $path = '/sites/v2/connect', ?string $authorization = null ): bool {

Expand Down Expand Up @@ -239,7 +245,7 @@ public function is_throttled() {
*
* @used-by Events::create_item()
*
* @param Event $event
* @param Event $event the event
*
* @phpstan-type Notification_Array array{id:string,locations:array,query:string|null,expiration:int,content:string}
* @return array<Notification_Array>|WP_Error
Expand All @@ -264,7 +270,10 @@ public function send_event( Event $event ) {
return new \WP_Error( $status_code, \wp_remote_retrieve_response_message( $hiive_response ) );
}

/** @var array{data:array{id:string,locations:array,query:string|null,expiration:int,content:string}} $response_payload */
/**
* Sample shape.
* @var array{data:array{id:string,locations:array,query:string|null,expiration:int,content:string}} $response_payload
* */
$response_payload = json_decode( \wp_remote_retrieve_body( $hiive_response ), true );

return $response_payload['data'] ?? array();
Expand Down Expand Up @@ -293,7 +302,7 @@ public function notify( $events ) {
return $hiive_response;
}

if ( ! in_array( \wp_remote_retrieve_response_code( $hiive_response ), array( 200, 201, 500 ) ) ) {
if ( ! in_array( \wp_remote_retrieve_response_code( $hiive_response ), array( 200, 201, 500 ), true ) ) {
return new WP_Error( \wp_remote_retrieve_response_code( $hiive_response ), \wp_remote_retrieve_response_message( $hiive_response ) );
}

Expand All @@ -315,14 +324,15 @@ public function notify( $events ) {
* Defaults to POST. Override with `$args = array('method' => 'GET')`.
*
* @param string $path The Hiive api path (after /api/).
* @param array|null $payload
* @param array|null $args
* @param array|null $payload the payload
* @param array|null $args and args for the request
*
* @return array|WP_Error The response array or a WP_Error when no Hiive connection, no network connection, network requests disabled.
*/
public function hiive_request( string $path, ?array $payload = array(), ?array $args = array() ) {

/**
* Add plugin name/version to user agent
* @see \WP_Http::request()
* @see https://developer.wordpress.org/reference/hooks/http_headers_useragent/
*/
Expand Down

0 comments on commit c38bc54

Please sign in to comment.