Code Duplication    Length = 22-23 lines in 2 locations

includes/api/class-wc-rest-shipping-methods-controller.php 1 location

@@ 40-61 (lines=22) @@
37
	/**
38
	 * Register the route for /shipping_methods and /shipping_methods/<method>
39
	 */
40
	public function register_routes() {
41
        register_rest_route( $this->namespace, '/' . $this->rest_base, array(
42
			array(
43
				'methods'             => WP_REST_Server::READABLE,
44
				'callback'            => array( $this, 'get_items' ),
45
                'permission_callback' => array( $this, 'get_items_permissions_check' ),
46
				'args'                => $this->get_collection_params(),
47
			),
48
			'schema' => array( $this, 'get_public_item_schema' ),
49
		) );
50
        register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\w-]+)', array(
51
			array(
52
				'methods'             => WP_REST_Server::READABLE,
53
				'callback'            => array( $this, 'get_item' ),
54
				'permission_callback' => array( $this, 'get_item_permissions_check' ),
55
				'args'                => array(
56
					'context' => $this->get_context_param( array( 'default' => 'view' ) ),
57
				),
58
			),
59
			'schema' => array( $this, 'get_public_item_schema' ),
60
		) );
61
	}
62
63
    /**
64
	 * Check whether a given request has permission to view system status.

includes/api/class-wc-rest-webhook-deliveries.php 1 location

@@ 42-64 (lines=23) @@
39
	/**
40
	 * Register the routes for webhook deliveries.
41
	 */
42
	public function register_routes() {
43
		register_rest_route( $this->namespace, '/' . $this->rest_base, array(
44
			array(
45
				'methods'             => WP_REST_Server::READABLE,
46
				'callback'            => array( $this, 'get_items' ),
47
				'permission_callback' => array( $this, 'get_items_permissions_check' ),
48
				'args'                => $this->get_collection_params(),
49
			),
50
			'schema' => array( $this, 'get_public_item_schema' ),
51
		) );
52
53
		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
54
			array(
55
				'methods'             => WP_REST_Server::READABLE,
56
				'callback'            => array( $this, 'get_item' ),
57
				'permission_callback' => array( $this, 'get_item_permissions_check' ),
58
				'args'                => array(
59
					'context' => $this->get_context_param( array( 'default' => 'view' ) ),
60
				),
61
			),
62
			'schema' => array( $this, 'get_public_item_schema' ),
63
		) );
64
	}
65
66
	/**
67
	 * Check whether a given request has permission to read webhook deliveries.