The class Shop_Form_OrderCreate has 11 public methods. Consider refactoring Shop_Form_OrderCreate to keep number of public methods under 10. Open
class Shop_Form_OrderCreate extends Pluf_Form
{
public $user = null;
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
Method initFields
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function initFields($extra = array())
{
$this->user = $extra['user'];
$this->fields['title'] = new Pluf_Form_Field_Varchar(array(
Missing class import via use statement (line '80', column '23'). Open
throw new Pluf_Exception_Form('cannot save the order from an invalid form', $this);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '57', column '40'). Open
$this->fields['address'] = new Pluf_Form_Field_Varchar(array(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '21', column '38'). Open
$this->fields['title'] = new Pluf_Form_Field_Varchar(array(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '33', column '38'). Open
$this->fields['phone'] = new Pluf_Form_Field_Varchar(array(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '39', column '38'). Open
$this->fields['email'] = new Pluf_Form_Field_Email(array(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '63', column '38'). Open
$this->fields['point'] = new Pluf_Form_Field_Geometry(array(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '51', column '37'). Open
$this->fields['city'] = new Pluf_Form_Field_Varchar(array(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '69', column '44'). Open
$this->fields['description'] = new Pluf_Form_Field_Varchar(array(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '27', column '42'). Open
$this->fields['full_name'] = new Pluf_Form_Field_Varchar(array(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method save has a boolean flag argument $commit, which is a certain sign of a Single Responsibility Principle violation. Open
function save($commit = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '83', column '22'). Open
$order = new Shop_Order();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '45', column '41'). Open
$this->fields['province'] = new Pluf_Form_Field_Varchar(array(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Define a constant instead of duplicating this literal "required" 9 times. Open
'required' => false,
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "label" 9 times. Open
'label' => 'Order Title',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "help_text" 9 times. Open
'help_text' => 'Title for order'
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Shop_Form_OrderCreate extends Pluf_Form
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 12 and the first side effect is on line 2. Open
<?php
- Exclude checks
The class Shop_Form_OrderCreate is not named in CamelCase. Open
class Shop_Form_OrderCreate extends Pluf_Form
{
public $user = null;
- 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
Method name "Shop_Form_OrderCreate::clean_point" is not in camel caps format Open
public function clean_point()
- Exclude checks
Method name "Shop_Form_OrderCreate::clean_address" is not in camel caps format Open
public function clean_address()
- Exclude checks
Method name "Shop_Form_OrderCreate::clean_description" is not in camel caps format Open
public function clean_description()
- Exclude checks
Visibility must be declared on method "save" Open
function save($commit = true)
- Exclude checks
Method name "Shop_Form_OrderCreate::clean_phone" is not in camel caps format Open
public function clean_phone()
- Exclude checks
Method name "Shop_Form_OrderCreate::clean_province" is not in camel caps format Open
public function clean_province()
- Exclude checks
Method name "Shop_Form_OrderCreate::clean_email" is not in camel caps format Open
public function clean_email()
- Exclude checks
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
}
- Exclude checks
Method name "Shop_Form_OrderCreate::clean_full_name" is not in camel caps format Open
public function clean_full_name()
- Exclude checks
Method name "Shop_Form_OrderCreate::clean_city" is not in camel caps format Open
public function clean_city()
- Exclude checks
Class name "Shop_Form_OrderCreate" is not in camel caps format Open
class Shop_Form_OrderCreate extends Pluf_Form
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
The method clean_email is not named in camelCase. Open
public function clean_email()
{
$email = mb_strtolower(trim($this->cleaned_data['email']));
// TODO: hadi 1395-01-26: بررسی صحت ایمیل
return $email;
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method clean_phone is not named in camelCase. Open
public function clean_phone()
{
$phone = trim($this->cleaned_data['phone']);
return $phone;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method clean_full_name is not named in camelCase. Open
public function clean_full_name()
{
$fullname = trim($this->cleaned_data['full_name']);
return $fullname;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method clean_city is not named in camelCase. Open
public function clean_city()
{
$val = trim($this->cleaned_data['city']);
return $val;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method clean_description is not named in camelCase. Open
public function clean_description()
{
$extraInfo = trim($this->cleaned_data['description']);
return $extraInfo;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method clean_province is not named in camelCase. Open
public function clean_province()
{
$province = trim($this->cleaned_data['province']);
return $province;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method clean_address is not named in camelCase. Open
public function clean_address()
{
$val= trim($this->cleaned_data['address']);
return $val;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method clean_point is not named in camelCase. Open
public function clean_point()
{
$val= trim($this->cleaned_data['point']);
return $val;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}