File class-wc-webhook.php
has 491 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Webhook
*
* This class handles storing and retrieving webhook data from the associated.
WC_Webhook
has 50 functions (exceeds 20 allowed). Consider refactoring. Open
class WC_Webhook extends WC_Legacy_Webhook {
/**
* Store which object IDs this webhook has processed (ie scheduled to be delivered)
* within the current page request.
Method get_topic_hooks
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function get_topic_hooks( $topic ) {
$topic_hooks = array(
'coupon.created' => array(
'woocommerce_process_shop_coupon_meta',
'woocommerce_new_coupon',
Method log_delivery
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function log_delivery( $delivery_id, $request, $response, $duration ) {
$logger = wc_get_logger();
$message = array(
'Webhook Delivery' => array(
'Delivery ID' => $delivery_id,
Method get_legacy_api_payload
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function get_legacy_api_payload( $resource, $resource_id, $event ) {
// Include & load API classes.
WC()->api->includes();
WC()->api->register_resources( new WC_API_Server( '/' ) );
Method deliver
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function deliver( $arg ) {
$start_time = microtime( true );
$payload = $this->build_payload( $arg );
// Setup request args.
Function get_legacy_api_payload
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function get_legacy_api_payload( $resource, $resource_id, $event ) {
// Include & load API classes.
WC()->api->includes();
WC()->api->register_resources( new WC_API_Server( '/' ) );
- 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_valid_resource
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function is_valid_resource( $arg ) {
$resource = $this->get_resource();
if ( in_array( $resource, array( 'order', 'product', 'coupon' ), true ) ) {
$status = get_post_status( absint( $arg ) );
- 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_wp_api_payload
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function get_wp_api_payload( $resource, $resource_id, $event ) {
switch ( $resource ) {
case 'coupon':
case 'customer':
case '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
Function log_delivery
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function log_delivery( $delivery_id, $request, $response, $duration ) {
$logger = wc_get_logger();
$message = array(
'Webhook Delivery' => array(
'Delivery ID' => $delivery_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 __construct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( $data = 0 ) {
parent::__construct( $data );
if ( $data instanceof WC_Webhook ) {
$this->set_id( absint( $data->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"