File class-sv-wc-helper.php
has 427 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Plugin Framework
*
* This source file is subject to the GNU General Public License v3.0
Function array_to_xml
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
public static function array_to_xml( $xml_writer, $element_key, $element_value = array() ) {
if ( is_array( $element_value ) ) {
// handle attributes
- 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
SV_WC_Helper
has 36 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
class SV_WC_Helper {
/** encoding used for mb_*() string functions */
Method render_select2_ajax
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function render_select2_ajax() {
if ( ! did_action( 'sv_wc_select2_ajax_rendered' ) ) {
$javascript = "( function(){
Consider simplifying this complex logical expression. Open
if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_12_4\\SV_WC_Helper' ) ) :
/**
* SkyVerge Helper Class
Function get_order_line_items
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function get_order_line_items( $order ): array {
$line_items = [];
/** @var \WC_Order_Item_Product $item */
- 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_order_line_items
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get_order_line_items( $order ): array {
$line_items = [];
/** @var \WC_Order_Item_Product $item */
Method array_to_xml
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function array_to_xml( $xml_writer, $element_key, $element_value = array() ) {
if ( is_array( $element_value ) ) {
// handle attributes
Function str_exists
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function str_exists( $haystack, $needle ) {
if ( self::multibyte_loaded() ) {
if ( '' === $needle ) {
- 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 list_array_items
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function list_array_items( array $items, $conjunction = null, $separator = '' ) {
if ( ! is_string( $conjunction ) ) {
$conjunction = _x( 'and', 'coordinating conjunction for a list of items: a, b, and c', 'woocommerce-plugin-framework' );
}
- 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 str_starts_with
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function str_starts_with( $haystack, $needle ) {
if ( self::multibyte_loaded() ) {
if ( '' === $needle ) {
- 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 array_insert_after
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function array_insert_after( Array $array, $insert_key, Array $element ) {
$new_array = array();
foreach ( $array as $key => $value ) {
- 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 str_truncate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function str_truncate( $string, $length, $omission = '...' ) {
if ( self::multibyte_loaded() ) {
// bail if string doesn't need to be truncated
- 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 trigger_error
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function trigger_error( $message, $type = E_USER_NOTICE ) {
if ( is_callable( 'wp_doing_ajax' ) && wp_doing_ajax() ) {
switch ( $type ) {
- 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 array_join_natural
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function array_join_natural( array $array, ?string $conjunction = 'and', ?string $pattern = '' ) : string
{
$last = array_pop( $array );
if ( $array ) {
- 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 is_order_virtual
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function is_order_virtual( \WC_Order $order ) {
$is_virtual = true;
/** @var \WC_Order_Item_Product $item */
- 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 is_rest_api_request
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function is_rest_api_request() {
if ( is_callable( 'WC' ) && is_callable( [ WC(), 'is_rest_api_request' ] ) ) {
return (bool) WC()->is_rest_api_request();
}
- 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"