Function get_tokens
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
public function get_tokens( $user_id, $args = array() ) {
// default to current environment
if ( ! isset( $args['environment_id'] ) ) {
$args['environment_id'] = $this->get_environment_id();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File class-sv-wc-payment-gateway-payment-tokens-handler.php
has 490 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Payment Gateway Framework
*
* This source file is subject to the GNU General Public License v3.0
SV_WC_Payment_Gateway_Payment_Tokens_Handler
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
class SV_WC_Payment_Gateway_Payment_Tokens_Handler {
/** @var string the gateway environment ID */
Function create_token
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public function create_token( \WC_Order $order, $response = null, $environment_id = null ) {
$gateway = $this->get_gateway();
// default to current environment
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method get_tokens
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_tokens( $user_id, $args = array() ) {
// default to current environment
if ( ! isset( $args['environment_id'] ) ) {
$args['environment_id'] = $this->get_environment_id();
Function delete_token
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function delete_token( $user_id, SV_WC_Payment_Gateway_Payment_Token $token, $environment_id = null ) {
// default to current environment
if ( null === $environment_id ) {
$environment_id = $this->get_environment_id();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function add_token
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function add_token( $user_id, $token, $environment_id = null ) {
// default to current environment
if ( is_null( $environment_id ) ) {
$environment_id = $this->get_environment_id();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function merge_token_data
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function merge_token_data( $local_tokens, $remote_tokens ) {
foreach ( $remote_tokens as &$remote_token ) {
$remote_token_id = $remote_token->get_id();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function update_tokens
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function update_tokens( $user_id, $tokens, $environment_id = null ) {
// default to current environment
if ( is_null( $environment_id ) ) {
$environment_id = $this->get_environment_id();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method create_token
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create_token( \WC_Order $order, $response = null, $environment_id = null ) {
$gateway = $this->get_gateway();
// default to current environment
Function set_default_token
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function set_default_token( $user_id, $token, $environment_id = null ) {
// default to current environment
if ( is_null( $environment_id ) ) {
$environment_id = $this->get_environment_id();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function remove_token
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function remove_token( $user_id, $token, $environment_id = null ) {
// default to current environment
if ( is_null( $environment_id ) ) {
$environment_id = $this->get_environment_id();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method add_token
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add_token( $user_id, $token, $environment_id = null ) {
// default to current environment
if ( is_null( $environment_id ) ) {
$environment_id = $this->get_environment_id();
Method delete_token
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function delete_token( $user_id, SV_WC_Payment_Gateway_Payment_Token $token, $environment_id = null ) {
// default to current environment
if ( null === $environment_id ) {
$environment_id = $this->get_environment_id();
Function remove_token_from_gateway
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function remove_token_from_gateway( $user_id, $environment_id, $token ) {
// remove a token's local data unless an exception occurs or we choose to keep loca data based on the API response
$remove_local_data = true;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function update_legacy_token
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function update_legacy_token( $user_id, $token, $environment_id = null, $migrated = false ) {
$updated = false;
// default to current environment
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if ( $legacy_token->save() ) {
$tokens[ $legacy_token->get_id() ] = $legacy_token;
$migrated_tokens++;
Function get_token_by_core_id
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function get_token_by_core_id( int $user_id, int $core_token_id, string $environment_id = null ): ?SV_WC_Payment_Gateway_Payment_Token
{
// default to current environment
if ( is_null( $environment_id ) ) {
$environment_id = $this->get_environment_id();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_legacy_tokens
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_legacy_tokens( $user_id, $environment_id = null ) {
if ( null === $environment_id ) {
$environment_id = $this->get_environment_id();
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function payment_token_deleted
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function payment_token_deleted( $token_id, $core_token ) {
if ( $this->get_gateway()->get_id() === $core_token->get_gateway_id() ) {
$token = $this->build_token( $core_token->get_token(), $core_token );
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function update_token
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function update_token( $user_id, $token, $environment_id = null ) {
// default to current environment
if ( null === $environment_id ) {
$environment_id = $this->get_environment_id();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"