@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | * @return bool |
| 133 | 133 | */ |
| 134 | 134 | public function has_valid_action(): bool { |
| 135 | - return is_string( $this->get_action() ) |
|
| 136 | - && \mb_strlen( $this->get_action() ) > 0; |
|
| 135 | + return is_string($this->get_action()) |
|
| 136 | + && \mb_strlen($this->get_action()) > 0; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -142,6 +142,6 @@ discard block |
||
| 142 | 142 | * @return bool |
| 143 | 143 | */ |
| 144 | 144 | public function has_nonce(): bool { |
| 145 | - return ! is_null( $this->get_nonce_handle() ); |
|
| 145 | + return ! is_null($this->get_nonce_handle()); |
|
| 146 | 146 | } |
| 147 | 147 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | 51 | public static function admin_ajax_url(): string { |
| 52 | - return admin_url( 'admin-ajax.php' ); |
|
| 52 | + return admin_url('admin-ajax.php'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -60,17 +60,17 @@ discard block |
||
| 60 | 60 | * @return Ajax |
| 61 | 61 | * @throws Ajax_Exception (code 100) If non valid Ajax class passed. |
| 62 | 62 | */ |
| 63 | - private static function get_reflected( string $class ): Ajax { |
|
| 64 | - if ( ! \is_subclass_of( $class, Ajax::class ) ) { |
|
| 65 | - throw Ajax_Exception::non_ajax_model( 'get reflection' ); |
|
| 63 | + private static function get_reflected(string $class): Ajax { |
|
| 64 | + if ( ! \is_subclass_of($class, Ajax::class)) { |
|
| 65 | + throw Ajax_Exception::non_ajax_model('get reflection'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if ( ! array_key_exists( $class, self::$class_cache ) ) { |
|
| 69 | - $reflection = new ReflectionClass( $class ); |
|
| 70 | - self::$class_cache[ $class ] = $reflection->newInstanceWithoutConstructor(); |
|
| 68 | + if ( ! array_key_exists($class, self::$class_cache)) { |
|
| 69 | + $reflection = new ReflectionClass($class); |
|
| 70 | + self::$class_cache[$class] = $reflection->newInstanceWithoutConstructor(); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - return self::$class_cache[ $class ]; |
|
| 73 | + return self::$class_cache[$class]; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | * @throws Ajax_Exception (code 100) If non valid Ajax class passed. |
| 83 | 83 | * @throws Ajax_Exception (code 101) If no action defined |
| 84 | 84 | */ |
| 85 | - public static function get_action( string $class ):? string { |
|
| 86 | - $instance = self::get_reflected( $class ); |
|
| 85 | + public static function get_action(string $class): ? string { |
|
| 86 | + $instance = self::get_reflected($class); |
|
| 87 | 87 | |
| 88 | - if ( ! $instance->has_valid_action() ) { |
|
| 89 | - throw Ajax_Exception::undefined_action( $class ); |
|
| 88 | + if ( ! $instance->has_valid_action()) { |
|
| 89 | + throw Ajax_Exception::undefined_action($class); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $instance->get_action(); |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | * @return boolean |
| 100 | 100 | * @throws Ajax_Exception (code 100) If non valid Ajax class passed. |
| 101 | 101 | */ |
| 102 | - public static function has_nonce( string $class ): bool { |
|
| 103 | - return self::get_reflected( $class )->has_nonce(); |
|
| 102 | + public static function has_nonce(string $class): bool { |
|
| 103 | + return self::get_reflected($class)->has_nonce(); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | * @return Nonce|null |
| 111 | 111 | * @throws Ajax_Exception (code 100) If non valid Ajax class passed. |
| 112 | 112 | */ |
| 113 | - public static function get_nonce( string $class ): ?Nonce { |
|
| 114 | - $instance = self::get_reflected( $class ); |
|
| 113 | + public static function get_nonce(string $class): ?Nonce { |
|
| 114 | + $instance = self::get_reflected($class); |
|
| 115 | 115 | |
| 116 | 116 | return $instance->has_nonce() |
| 117 | - ? new Nonce( $instance->get_nonce_handle() ?? '' ) // has_nonce conditional should catch null here |
|
| 117 | + ? new Nonce($instance->get_nonce_handle() ?? '') // has_nonce conditional should catch null here |
|
| 118 | 118 | : null; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * @return string |
| 126 | 126 | * @throws Ajax_Exception (code 100) If non valid Ajax class passed. |
| 127 | 127 | */ |
| 128 | - public static function get_nonce_field( string $class ): string { |
|
| 129 | - return self::get_reflected( $class )->get_nonce_field(); |
|
| 128 | + public static function get_nonce_field(string $class): string { |
|
| 129 | + return self::get_reflected($class)->get_nonce_field(); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -136,14 +136,14 @@ discard block |
||
| 136 | 136 | * @param ServerRequestInterface $request |
| 137 | 137 | * @return array<string, string> |
| 138 | 138 | */ |
| 139 | - public static function extract_server_request_args( ServerRequestInterface $request ): array { |
|
| 140 | - switch ( $request->getMethod() ) { |
|
| 139 | + public static function extract_server_request_args(ServerRequestInterface $request): array { |
|
| 140 | + switch ($request->getMethod()) { |
|
| 141 | 141 | case 'POST': |
| 142 | 142 | // Return different post types. |
| 143 | - if ( str_contains( $request->getHeaderLine( 'Content-Type' ), 'application/x-www-form-urlencoded;' ) ) { |
|
| 143 | + if (str_contains($request->getHeaderLine('Content-Type'), 'application/x-www-form-urlencoded;')) { |
|
| 144 | 144 | $params = (array) $request->getParsedBody(); |
| 145 | 145 | } else { |
| 146 | - $params = json_decode( (string) $request->getBody(), true ) ?? array(); |
|
| 146 | + $params = json_decode((string) $request->getBody(), true) ?? array(); |
|
| 147 | 147 | } |
| 148 | 148 | break; |
| 149 | 149 | case 'GET': |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | * @param string $operation The operation being carries out. |
| 35 | 35 | * @return Ajax_Exception |
| 36 | 36 | */ |
| 37 | - public static function non_ajax_model( string $operation = 'unknown operation' ): Ajax_Exception { |
|
| 37 | + public static function non_ajax_model(string $operation = 'unknown operation'): Ajax_Exception { |
|
| 38 | 38 | $message = 'None Ajax Model passed to ' . $operation; |
| 39 | - return new Ajax_Exception( $message, 100 ); |
|
| 39 | + return new Ajax_Exception($message, 100); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | * @param string $class Ajax class |
| 46 | 46 | * @return Ajax_Exception |
| 47 | 47 | */ |
| 48 | - public static function undefined_action( string $class ): Ajax_Exception { |
|
| 48 | + public static function undefined_action(string $class): Ajax_Exception { |
|
| 49 | 49 | $message = "{$class} has no defined action property"; |
| 50 | - return new Ajax_Exception( $message, 101 ); |
|
| 50 | + return new Ajax_Exception($message, 101); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | * @param \PinkCrab\Ajax\Ajax $ajax_class |
| 65 | 65 | * @return bool |
| 66 | 66 | */ |
| 67 | - public function validate_request( Ajax $ajax_class ): bool { |
|
| 68 | - return $this->request_validator->validate( $ajax_class ); |
|
| 67 | + public function validate_request(Ajax $ajax_class): bool { |
|
| 68 | + return $this->request_validator->validate($ajax_class); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | * @return \Psr\Http\Message\ResponseInterface |
| 76 | 76 | * @filter Ajax_Hooks::CALLBACK_REQUEST_FILTER |
| 77 | 77 | */ |
| 78 | - public function invoke_callback( Ajax $ajax_class ): ResponseInterface { |
|
| 78 | + public function invoke_callback(Ajax $ajax_class): ResponseInterface { |
|
| 79 | 79 | return $ajax_class->callback( |
| 80 | - \apply_filters( Ajax_Hooks::CALLBACK_REQUEST_FILTER, $this->server_request, $ajax_class ), |
|
| 80 | + \apply_filters(Ajax_Hooks::CALLBACK_REQUEST_FILTER, $this->server_request, $ajax_class), |
|
| 81 | 81 | $this->response_factory |
| 82 | 82 | ); |
| 83 | 83 | } |
@@ -91,32 +91,32 @@ discard block |
||
| 91 | 91 | * @action Ajax_Hooks::CALLBACK_EXECUTION_EXCEPTION |
| 92 | 92 | * @filter Ajax_Hooks::CALLBACK_RESPONSE_FILTER |
| 93 | 93 | */ |
| 94 | - public function create_callback( Ajax $ajax_class ): Closure { |
|
| 94 | + public function create_callback(Ajax $ajax_class): Closure { |
|
| 95 | 95 | /** |
| 96 | 96 | * @param \PinkCrab\Ajax\Ajax $ajax_class |
| 97 | 97 | * @return noreturn |
| 98 | 98 | */ |
| 99 | - return function() use ( $ajax_class ): void { |
|
| 99 | + return function() use ($ajax_class): void { |
|
| 100 | 100 | |
| 101 | 101 | $valid_nonce = apply_filters( |
| 102 | 102 | Ajax_Hooks::REQUEST_NONCE_VERIFICATION, |
| 103 | - $this->validate_request( $ajax_class ), |
|
| 103 | + $this->validate_request($ajax_class), |
|
| 104 | 104 | $ajax_class, |
| 105 | 105 | $this->server_request |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | try { |
| 109 | 109 | $response = $valid_nonce |
| 110 | - ? $this->invoke_callback( $ajax_class ) |
|
| 110 | + ? $this->invoke_callback($ajax_class) |
|
| 111 | 111 | : $this->response_factory->unauthorised(); |
| 112 | - } catch ( Exception $th ) { |
|
| 112 | + } catch (Exception $th) { |
|
| 113 | 113 | |
| 114 | - do_action( Ajax_Hooks::CALLBACK_EXECUTION_EXCEPTION, $th, $ajax_class ); |
|
| 114 | + do_action(Ajax_Hooks::CALLBACK_EXECUTION_EXCEPTION, $th, $ajax_class); |
|
| 115 | 115 | |
| 116 | - $response = $this->response_factory->failure( array( 'error' => $th->getMessage() ) ); |
|
| 116 | + $response = $this->response_factory->failure(array('error' => $th->getMessage())); |
|
| 117 | 117 | } |
| 118 | 118 | $this->http_helper->emit_psr7_response( |
| 119 | - \apply_filters( Ajax_Hooks::CALLBACK_RESPONSE_FILTER, $response, $ajax_class, $this->server_request ) |
|
| 119 | + \apply_filters(Ajax_Hooks::CALLBACK_RESPONSE_FILTER, $response, $ajax_class, $this->server_request) |
|
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | 122 | \wp_die(); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public Ajax_Dispatcher $dispatcher; |
| 24 | 24 | |
| 25 | - public function __construct( Ajax_Dispatcher $dispatcher ) { |
|
| 25 | + public function __construct(Ajax_Dispatcher $dispatcher) { |
|
| 26 | 26 | $this->dispatcher = $dispatcher; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | * @param object $class |
| 33 | 33 | * @return object |
| 34 | 34 | */ |
| 35 | - public function process( object $class ): object { |
|
| 36 | - if ( is_a( $class, Ajax::class ) |
|
| 35 | + public function process(object $class): object { |
|
| 36 | + if (is_a($class, Ajax::class) |
|
| 37 | 37 | && is_admin() |
| 38 | 38 | && wp_doing_ajax() |
| 39 | 39 | ) { |
| 40 | - $this->dispatcher->add_ajax_call( $class ); |
|
| 40 | + $this->dispatcher->add_ajax_call($class); |
|
| 41 | 41 | } |
| 42 | 42 | return $class; |
| 43 | 43 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | class Ajax implements Module { |
| 25 | 25 | |
| 26 | - public function __construct( DI_Container $di_container ) { |
|
| 26 | + public function __construct(DI_Container $di_container) { |
|
| 27 | 27 | $di_container->addRule( |
| 28 | 28 | '*', |
| 29 | 29 | array( |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | ## Unused methods |
| 45 | - public function pre_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 46 | - public function pre_boot( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 47 | - public function post_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 45 | + public function pre_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 46 | + public function pre_boot(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 47 | + public function post_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 48 | 48 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | protected ServerRequestInterface $server_request; |
| 35 | 35 | |
| 36 | - public function __construct( ServerRequestInterface $server_request ) { |
|
| 36 | + public function __construct(ServerRequestInterface $server_request) { |
|
| 37 | 37 | $this->server_request = $server_request; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,22 +43,22 @@ discard block |
||
| 43 | 43 | * @param \PinkCrab\Ajax\Ajax $ajax |
| 44 | 44 | * @return bool |
| 45 | 45 | */ |
| 46 | - public function validate( Ajax $ajax ): bool { |
|
| 47 | - if ( ! $ajax->has_nonce() ) { |
|
| 46 | + public function validate(Ajax $ajax): bool { |
|
| 47 | + if ( ! $ajax->has_nonce()) { |
|
| 48 | 48 | return true; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // Find nonce value in request |
| 52 | - $nonce_value = $this->find_nonce( $ajax->get_nonce_field() ); |
|
| 52 | + $nonce_value = $this->find_nonce($ajax->get_nonce_field()); |
|
| 53 | 53 | |
| 54 | 54 | // If no nonce value found in request. |
| 55 | - if ( is_null( $nonce_value ) ) { |
|
| 55 | + if (is_null($nonce_value)) { |
|
| 56 | 56 | return false; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /* @phpstan-ignore-next-line, nonce handle checked at start of method*/ |
| 60 | - return ( new Nonce( $ajax->get_nonce_handle() ) ) |
|
| 61 | - ->validate( $nonce_value ); |
|
| 60 | + return (new Nonce($ajax->get_nonce_handle())) |
|
| 61 | + ->validate($nonce_value); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | * @param string $nonce_field |
| 68 | 68 | * @return string|null |
| 69 | 69 | */ |
| 70 | - protected function find_nonce( string $nonce_field ): ?string { |
|
| 71 | - $args = Ajax_Helper::extract_server_request_args( $this->server_request ); |
|
| 70 | + protected function find_nonce(string $nonce_field): ?string { |
|
| 71 | + $args = Ajax_Helper::extract_server_request_args($this->server_request); |
|
| 72 | 72 | |
| 73 | - return \array_key_exists( $nonce_field, $args ) |
|
| 74 | - ? $args[ $nonce_field ] |
|
| 73 | + return \array_key_exists($nonce_field, $args) |
|
| 74 | + ? $args[$nonce_field] |
|
| 75 | 75 | : null; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | protected Hook_Loader $loader; |
| 35 | 35 | protected Ajax_Controller $ajax_controller; |
| 36 | 36 | |
| 37 | - public function __construct( Ajax_Controller $ajax_controller ) { |
|
| 37 | + public function __construct(Ajax_Controller $ajax_controller) { |
|
| 38 | 38 | $this->loader = new Hook_Loader(); |
| 39 | 39 | $this->ajax_controller = $ajax_controller; |
| 40 | 40 | } |
@@ -46,15 +46,15 @@ discard block |
||
| 46 | 46 | * @return void |
| 47 | 47 | * @throws Ajax_Exception (code 101) If no action defined |
| 48 | 48 | */ |
| 49 | - public function add_ajax_call( Ajax $ajax ): void { |
|
| 49 | + public function add_ajax_call(Ajax $ajax): void { |
|
| 50 | 50 | |
| 51 | - if ( ! $ajax->has_valid_action() ) { |
|
| 52 | - throw Ajax_Exception::undefined_action( \get_class( $ajax ) ); |
|
| 51 | + if ( ! $ajax->has_valid_action()) { |
|
| 52 | + throw Ajax_Exception::undefined_action(\get_class($ajax)); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $this->loader->ajax( |
| 56 | 56 | $ajax->get_action(), /* @phpstan-ignore-line, action existance checked above */ |
| 57 | - $this->ajax_controller->create_callback( $ajax ), |
|
| 57 | + $this->ajax_controller->create_callback($ajax), |
|
| 58 | 58 | $ajax->get_logged_out(), |
| 59 | 59 | $ajax->get_logged_in() |
| 60 | 60 | ); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | protected HTTP $http; |
| 36 | 36 | |
| 37 | - public function __construct( HTTP $http ) { |
|
| 37 | + public function __construct(HTTP $http) { |
|
| 38 | 38 | $this->http = $http; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | * @param int $code The HTTP status code. Defaults to 200. |
| 45 | 45 | * @param string $reasonPhrase |
| 46 | 46 | */ |
| 47 | - public function createResponse( int $code = 200, string $reasonPhrase = '' ): ResponseInterface { |
|
| 47 | + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { |
|
| 48 | 48 | return $this->http->psr7_response() |
| 49 | - ->withStatus( $code ) |
|
| 50 | - ->withHeader( 'Content-Type', 'application/json; charset=' . get_option( 'blog_charset' ) ) |
|
| 51 | - ->withBody( Stream::create( $reasonPhrase ) ); |
|
| 49 | + ->withStatus($code) |
|
| 50 | + ->withHeader('Content-Type', 'application/json; charset=' . get_option('blog_charset')) |
|
| 51 | + ->withBody(Stream::create($reasonPhrase)); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | * @param array<mixed> $payload |
| 58 | 58 | * @return ResponseInterface |
| 59 | 59 | */ |
| 60 | - public function success( array $payload = array() ): ResponseInterface { |
|
| 61 | - return $this->createResponse( 200, json_encode( $payload ) ?: '' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode |
|
| 60 | + public function success(array $payload = array()): ResponseInterface { |
|
| 61 | + return $this->createResponse(200, json_encode($payload) ?: ''); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | * @param array<mixed> $payload |
| 69 | 69 | * @return ResponseInterface |
| 70 | 70 | */ |
| 71 | - public function unauthorised( array $payload = array( 'error' => 'unauthorised' ) ): ResponseInterface { |
|
| 72 | - return $this->createResponse( 401, json_encode( $payload ) ?: '' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode |
|
| 71 | + public function unauthorised(array $payload = array('error' => 'unauthorised')): ResponseInterface { |
|
| 72 | + return $this->createResponse(401, json_encode($payload) ?: ''); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | * @param array<mixed> $payload |
| 80 | 80 | * @return ResponseInterface |
| 81 | 81 | */ |
| 82 | - public function failure( array $payload = array( 'error' => 'error' ) ): ResponseInterface { |
|
| 83 | - return $this->createResponse( 500, json_encode( $payload ) ?: '' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode |
|
| 82 | + public function failure(array $payload = array('error' => 'error')): ResponseInterface { |
|
| 83 | + return $this->createResponse(500, json_encode($payload) ?: ''); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param array<mixed> $payload |
| 91 | 91 | * @return ResponseInterface |
| 92 | 92 | */ |
| 93 | - public function not_found( array $payload = array( 'error' => 'not found' ) ): ResponseInterface { |
|
| 94 | - return $this->createResponse( 404, json_encode( $payload ) ?: '' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode |
|
| 93 | + public function not_found(array $payload = array('error' => 'not found')): ResponseInterface { |
|
| 94 | + return $this->createResponse(404, json_encode($payload) ?: ''); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode |
|
| 95 | 95 | } |
| 96 | 96 | } |