File orders.php
has 545 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* POS Orders Class
* duck punches the WC REST API
Orders
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
class Orders {
/** @var string $base the route base */
protected $base = '/orders';
Function update_post_metadata
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function update_post_metadata( $null, $order_id, $meta_key, $meta_value, $prev_value ) {
// we want last update to _order_shipping after $order->calculate_taxes()
// set flag true on first pass
if ( $meta_key == '_order_shipping_tax' ) {
- 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 order_response
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function order_response( $order_data, $order, $fields, $server ) {
// add cashier data
$order_data['cashier'] = $this->add_cashier_details( $order );
- 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 remove_admin_emails
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function remove_admin_emails( WC_Emails $wc_emails ) {
// send 'woocommerce_low_stock_notification'
// send 'woocommerce_no_stock_notification'
// send 'woocommerce_product_on_backorder_notification'
remove_action(
Function create_order_data
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function create_order_data( array $data ) {
// add filters & actions for create order
add_filter( 'woocommerce_product_tax_class', array( $this, 'product_tax_class' ), 10, 2 );
add_filter( 'woocommerce_get_product_from_item', array( $this, 'get_product_from_item' ), 10, 3 );
- 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_order_note_data
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function create_order_note_data( $data, $order_id ) {
if ( ! isset( $data['email'] ) ) {
return $data;
}
Method order_response
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function order_response( $order_data, $order, $fields, $server ) {
// add cashier data
$order_data['cashier'] = $this->add_cashier_details( $order );
Method update_post_metadata
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update_post_metadata( $null, $order_id, $meta_key, $meta_value, $prev_value ) {
// we want last update to _order_shipping after $order->calculate_taxes()
// set flag true on first pass
if ( $meta_key == '_order_shipping_tax' ) {
Method create_order_data
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create_order_data( array $data ) {
// add filters & actions for create order
add_filter( 'woocommerce_product_tax_class', array( $this, 'product_tax_class' ), 10, 2 );
add_filter( 'woocommerce_get_product_from_item', array( $this, 'get_product_from_item' ), 10, 3 );
Function create_order_note_data
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static public function create_order_note_data( $data, $order_id ) {
if ( ! isset( $data['email'] ) ) {
return $data;
}
- 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 order_add_product
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function order_add_product( $order_id, $item_id, $product, $qty, $args ) {
Method update_post_metadata
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function update_post_metadata( $null, $order_id, $meta_key, $meta_value, $prev_value ) {
Function process_payment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function process_payment( $order_id, $data ) {
if ( ! isset( $data['payment_details'] ) ) {
return;
}
- 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 order_add_shipping
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function order_add_shipping( $order_id, $item_id, $rate ) {
$shipping_line = $this->get_shipping_line( $rate, $item_id );
if ( $shipping_line && isset( $shipping_line['tax'] ) ) {
$taxes = 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 order_add_product
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function order_add_product( $order_id, $item_id, $product, $qty, $args ) {
$id = isset( $product->id ) ? $product->id : false;
$id = isset( $product->variation_id ) ? $product->variation_id : $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"