Podcast
has 48 functions (exceeds 20 allowed). Consider refactoring. Open
class Podcast extends database_object implements library_item, CatalogItemInterface
{
protected const DB_TABLENAME = 'podcast';
/* Variables from DB */
The class Podcast has an overall complexity of 61 which is very high. The configured complexity threshold is 50. Open
class Podcast extends database_object implements library_item, CatalogItemInterface
{
protected const DB_TABLENAME = 'podcast';
/* Variables from DB */
- Exclude checks
The class Podcast has 18 fields. Consider redesigning Podcast to keep the number of fields under 15. Open
class Podcast extends database_object implements library_item, CatalogItemInterface
{
protected const DB_TABLENAME = 'podcast';
/* Variables from DB */
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
The class Podcast has 46 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class Podcast extends database_object implements library_item, CatalogItemInterface
{
protected const DB_TABLENAME = 'podcast';
/* Variables from DB */
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
Avoid unused parameters such as '$data'. Open
public function update(array $data)
- 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 '$details'. Open
public function format($details = true): void
- 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
syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Open
private int $id = 0;
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = $this->getPodcastRepository()->persist($this);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
private int $id = 0;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The parameter $filter_type is not named in camelCase. Open
public function get_medias(?string $filter_type = null): array
{
$medias = array();
if ($filter_type === null || $filter_type === 'podcast_episode') {
$episodes = $this->getEpisodeIds(PodcastEpisodeStateEnum::COMPLETED);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $podcast_id is not named in camelCase. Open
public function __construct($podcast_id = 0)
{
if (!$podcast_id) {
return;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}