mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
🚨 Fix psalm warnings
This commit is contained in:
parent
6aecfdad31
commit
7bd3c0b199
1 changed files with 13 additions and 9 deletions
|
@ -14,7 +14,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
|||
/**
|
||||
* Class TodosModel
|
||||
*
|
||||
* Handles the storage and retrieval of todo completion states in WordPress options table.
|
||||
* Handles the storage and retrieval of task completion states in WordPress options table.
|
||||
* Provides methods to get and update completion states with proper type casting.
|
||||
*/
|
||||
class TodosModel {
|
||||
|
@ -23,7 +23,7 @@ class TodosModel {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
const OPTION_NAME = 'ppcp_todos';
|
||||
protected const OPTION_NAME = 'ppcp_todos';
|
||||
|
||||
/**
|
||||
* Retrieves the formatted completion states from WordPress options.
|
||||
|
@ -35,10 +35,14 @@ class TodosModel {
|
|||
*/
|
||||
public function get() : array {
|
||||
$completion_states = get_option( self::OPTION_NAME, array() );
|
||||
|
||||
return array_map(
|
||||
static function ( $state ) {
|
||||
return (bool) $state;
|
||||
},
|
||||
/**
|
||||
* Ensures the task completion states are boolean values.
|
||||
*
|
||||
* @param mixed $state value to sanitize, as stored in the DB.
|
||||
*/
|
||||
static fn( $state ) => (bool) $state,
|
||||
$completion_states
|
||||
);
|
||||
}
|
||||
|
@ -49,7 +53,7 @@ class TodosModel {
|
|||
* Converts the provided data array and saves it to wp_options table.
|
||||
* Throws an exception if update fails.
|
||||
*
|
||||
* @param array $states Array of todo IDs and their completion states.
|
||||
* @param array $states Array of task IDs and their completion states.
|
||||
* @return void
|
||||
* @throws RuntimeException When the completion states update fails.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue