TextSanitizer
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class TextSanitizer {
/*
* Constructor of this class
* Gets allowed html tags from admin config settings
The class TextSanitizer has 27 public methods. Consider refactoring TextSanitizer to keep number of public methods under 10. Open
class TextSanitizer {
/*
* Constructor of this class
* Gets allowed html tags from admin config settings
- 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
The class TextSanitizer has 27 non-getter- and setter-methods. Consider refactoring TextSanitizer to keep number of methods under 25. Open
class TextSanitizer {
/*
* Constructor of this class
* Gets allowed html tags from admin config settings
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many 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'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
Missing class import via use statement (line '55', column '20'). Open
$instance = new TextSanitizer();
- 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 previewText has a boolean flag argument $html, which is a certain sign of a Single Responsibility Principle violation. Open
function &previewText($text, $html = false) {
- 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
The method displayText has a boolean flag argument $html, which is a certain sign of a Single Responsibility Principle violation. Open
function &displayText($text, $html = false) {
- 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
The method addSlashes has a boolean flag argument $force, which is a certain sign of a Single Responsibility Principle violation. Open
function addSlashes($text, $force = false) {
- 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
The method sanitizeForDisplay uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$text = $this->makeClickable($text);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method sanitizeForPreview uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$text = $this->makeClickable($text);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid unused parameters such as '$smiley'. Open
function makeTboxData4Preview($text, $smiley = 0) {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$smiley'. Open
function makeTboxData4Show($text, $smiley = 0) {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$force'. Open
function addSlashes($text, $force = false) {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Call to undeclared method \TextSanitizer::xoopsCodeDecode
Open
$text = $this->xoopsCodeDecode($text);
- Exclude checks
Call to undeclared method \TextSanitizer::displayTarea
Open
return $this->displayTarea($text, $html, $smiley, $xcode);
- Exclude checks
Call to undeclared method \TextSanitizer::xoopsCodeDecode
Open
$text = $this->xoopsCodeDecode($text);
- Exclude checks
Call to undeclared method \TextSanitizer::smiley
Open
$text = $this->smiley($text);
- Exclude checks
Call to undeclared method \TextSanitizer::previewTarea
Open
return $this->previewTarea($text, $html, $smiley, $xcode);
- Exclude checks
Call to undeclared method \TextSanitizer::smiley
Open
$text = $this->smiley($text);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class TextSanitizer {
- Exclude checks
Visibility must be declared on method "__construct" Open
function __construct() {}
- Exclude checks
Visibility must be declared on method "makeTareaData4Edit" Open
function makeTareaData4Edit($text) {
- Exclude checks
Visibility must be declared on method "oopsStripSlashesGPC" Open
function &oopsStripSlashesGPC($text) {
- Exclude checks
Visibility must be declared on method "sanitizeForPreview" Open
function sanitizeForPreview($text, $allowhtml = 0, $smiley = 1, $bbcode = 1) {
- Exclude checks
Visibility must be declared on method "makeTboxData4Preview" Open
function makeTboxData4Preview($text, $smiley = 0) {
- Exclude checks
Visibility must be declared on method "makeTboxData4PreviewInForm" Open
function makeTboxData4PreviewInForm($text) {
- Exclude checks
Visibility must be declared on method "stripSlashesGPC" Open
function stripSlashesGPC($text) {
- Exclude checks
Visibility must be declared on method "sanitizeForDisplay" Open
function sanitizeForDisplay($text, $allowhtml = 0, $smiley = 1, $bbcode = 1) {
- Exclude checks
Visibility must be declared on method "makeTareaData4InsideQuotes" Open
function makeTareaData4InsideQuotes($text) {
- Exclude checks
Visibility must be declared on method "oopsNl2Br" Open
function &oopsNl2Br($text) {
- Exclude checks
Visibility must be declared on method "makeTboxData4Save" Open
function makeTboxData4Save($text) {
- Exclude checks
Visibility must be declared on method "makeTboxData4Show" Open
function makeTboxData4Show($text, $smiley = 0) {
- Exclude checks
Visibility must be declared on method "makeTareaData4Show" Open
function &makeTareaData4Show(&$text, $html = 1, $smiley = 1, $xcode = 1) {
- Exclude checks
Visibility must be declared on method "makeTareaData4PreviewInForm" Open
function makeTareaData4PreviewInForm($text) {
- Exclude checks
Visibility must be declared on method "oopsHtmlSpecialChars" Open
function &oopsHtmlSpecialChars($text) {
- Exclude checks
Visibility must be declared on method "makeClickable" Open
function &makeClickable(&$text) {
- Exclude checks
Visibility must be declared on method "htmlSpecialChars" Open
function htmlSpecialChars($text) {
- Exclude checks
Visibility must be declared on method "getInstance" Open
function &getInstance() {
- Exclude checks
Visibility must be declared on method "makeTareaData4Save" Open
function makeTareaData4Save($text) {
- Exclude checks
Visibility must be declared on method "oopsStripSlashesRT" Open
function &oopsStripSlashesRT($text) {
- Exclude checks
Visibility must be declared on method "nl2Br" Open
function &nl2Br($text) {
- Exclude checks
Visibility must be declared on method "oopsAddSlashes" Open
function &oopsAddSlashes($text) {
- Exclude checks
Visibility must be declared on method "undoHtmlSpecialChars" Open
function undoHtmlSpecialChars(&$text) {
- Exclude checks
Visibility must be declared on method "addSlashes" Open
function addSlashes($text, $force = false) {
- Exclude checks
Visibility must be declared on method "displayText" Open
function &displayText($text, $html = false) {
- Exclude checks
Visibility must be declared on method "previewText" Open
function &previewText($text, $html = false) {
- Exclude checks
Visibility must be declared on method "makeTareaData4Preview" Open
function &makeTareaData4Preview(&$text, $html = 1, $smiley = 1, $xcode = 1) {
- Exclude checks
Visibility must be declared on method "makeTboxData4Edit" Open
function makeTboxData4Edit($text) {
- Exclude checks
Closing brace must be on a line by itself Open
function __construct() {}
- Exclude checks