Code Duplication    Length = 12-12 lines in 5 locations

includes/abstracts/abstract-wc-rest-terms-controller.php 5 locations

@@ 91-102 (lines=12) @@
88
	 * @param  WP_REST_Request $request Full details about the request.
89
	 * @return WP_Error|boolean
90
	 */
91
	public function get_items_permissions_check( $request ) {
92
		$permissions = $this->check_permissions( $request, 'read' );
93
		if ( is_wp_error( $permissions ) ) {
94
			return $permissions;
95
		}
96
97
		if ( ! $permissions ) {
98
			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
99
		}
100
101
		return true;
102
	}
103
104
	/**
105
	 * Check if a given request has access to create a term.
@@ 110-121 (lines=12) @@
107
	 * @param  WP_REST_Request $request Full details about the request.
108
	 * @return WP_Error|boolean
109
	 */
110
	public function create_item_permissions_check( $request ) {
111
		$permissions = $this->check_permissions( $request, 'create' );
112
		if ( is_wp_error( $permissions ) ) {
113
			return $permissions;
114
		}
115
116
		if ( ! $permissions ) {
117
			return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you cannot create new resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
118
		}
119
120
		return true;
121
	}
122
123
	/**
124
	 * Check if a given request has access to read a term.
@@ 129-140 (lines=12) @@
126
	 * @param  WP_REST_Request $request Full details about the request.
127
	 * @return WP_Error|boolean
128
	 */
129
	public function get_item_permissions_check( $request ) {
130
		$permissions = $this->check_permissions( $request, 'read' );
131
		if ( is_wp_error( $permissions ) ) {
132
			return $permissions;
133
		}
134
135
		if ( ! $permissions ) {
136
			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
137
		}
138
139
		return true;
140
	}
141
142
	/**
143
	 * Check if a given request has access to update a term.
@@ 148-159 (lines=12) @@
145
	 * @param  WP_REST_Request $request Full details about the request.
146
	 * @return WP_Error|boolean
147
	 */
148
	public function update_item_permissions_check( $request ) {
149
		$permissions = $this->check_permissions( $request, 'edit' );
150
		if ( is_wp_error( $permissions ) ) {
151
			return $permissions;
152
		}
153
154
		if ( ! $permissions ) {
155
			return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
156
		}
157
158
		return true;
159
	}
160
161
	/**
162
	 * Check if a given request has access to delete a term.
@@ 167-178 (lines=12) @@
164
	 * @param  WP_REST_Request $request Full details about the request.
165
	 * @return WP_Error|boolean
166
	 */
167
	public function delete_item_permissions_check( $request ) {
168
		$permissions = $this->check_permissions( $request, 'delete' );
169
		if ( is_wp_error( $permissions ) ) {
170
			return $permissions;
171
		}
172
173
		if ( ! $permissions ) {
174
			return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you cannot delete resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
175
		}
176
177
		return true;
178
	}
179
180
	/**
181
	 * Check permissions.