src/Shop/Order/Manager/SimplePreconditions.php
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
Open
static public function canUpdateOrder ($request, $order)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Shop_Order_Manager_SimplePreconditions
- Exclude checks
The class Shop_Order_Manager_SimplePreconditions is not named in CamelCase. Open
Open
class Shop_Order_Manager_SimplePreconditions
{
/**
* Checks if requester is allowed to update the order.
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Expected "function abc(...)"; found "function abc (...)" Open
Open
static public function canUpdateOrder ($request, $order)
- Exclude checks
Expected 0 spaces before opening parenthesis; 1 found Open
Open
static public function canUpdateOrder ($request, $order)
- Exclude checks
The static declaration must come after the visibility declaration Open
Open
static public function canUpdateOrder ($request, $order)
- Exclude checks
The closing brace for the class must go on the next line after the body Open
Open
}
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
Open
* Order could be updated if requester is owner of order or the feild 'secureId' is exsited in the request`s parameters.
- Exclude checks
Whitespace found at end of line Open
Open
*
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
Open
if($order->customer_id === $request->user->id){
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
Open
if(array_key_exists('secureId', $request->REQUEST) && $order->secureId === $request->REQUEST['secureId']){
- Exclude checks
Class name "Shop_Order_Manager_SimplePreconditions" is not in camel caps format Open
Open
class Shop_Order_Manager_SimplePreconditions
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
Open
if($order->customer_id === $request->user->id){
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
Open
if(array_key_exists('secureId', $request->REQUEST) && $order->secureId === $request->REQUEST['secureId']){
- Exclude checks