The method get_sample_text() has an NPath complexity of 291. The configured NPath complexity threshold is 200. Open
public function get_sample_text()
{
$sample_text = '';
foreach ($this->resources as $type => &$resources) {
if (count($resources) > 0) {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
Remove error control operator '@' on line 349. Open
public static function unserialize($course)
{
// Uncompress
if (function_exists('gzdeflate')) {
$inflated = @gzinflate($course);
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
The method unserialize uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$unserialized = UnserializeApi::unserialize(
'course',
$course
);
- 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 serialize uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$serialized = serialize($course);
}
- 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 local variables such as '$id'. Open
foreach ($resources as $id => &$resource) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
The property $destination_path is not named in camelCase. Open
class Course
{
public $resources;
public $code;
public $path;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $destination_db is not named in camelCase. Open
class Course
{
public $resources;
public $code;
public $path;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The parameter $resource_to_check is not named in camelCase. Open
public function is_linked_resource(&$resource_to_check): bool
{
foreach ($this->resources as $type => $resources) {
if (is_array($resources)) {
foreach ($resources as $resource) {
- 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
Method name "Course::get_sample_text" is not in camel caps format Open
public function get_sample_text()
- Exclude checks
Method name "Course::add_resource" is not in camel caps format Open
public function add_resource(&$resource)
- Exclude checks
Variable "survey_question_comment" is not in valid camel caps format Open
$resource->survey_question_comment = api_to_system_encoding($resource->survey_question_comment, $this->encoding);
- Exclude checks
Missing parameter name Open
* @param $resource
- Exclude checks
Variable "survey_question" is not in valid camel caps format Open
$title = $resource->survey_question;
- Exclude checks
Variable "sample_text" is not in valid camel caps format Open
$sample_text .= $description."\n";
- Exclude checks
Variable "topic_poster_name" is not in valid camel caps format Open
$resource->topic_poster_name = api_to_system_encoding($resource->topic_poster_name, $this->encoding);
- Exclude checks
Variable "poster_name" is not in valid camel caps format Open
$resource->poster_name = api_to_system_encoding($resource->poster_name, $this->encoding);
- Exclude checks
Method name "Course::is_linked_resource" is not in camel caps format Open
public function is_linked_resource(&$resource_to_check): bool
- Exclude checks
Variable "resource_to_check" is not in valid camel caps format Open
public function is_linked_resource(&$resource_to_check): bool
- Exclude checks
Variable "intro_text" is not in valid camel caps format Open
$description = $resource->intro_text;
- Exclude checks
Variable "sample_text" is not in valid camel caps format Open
$sample_text .= "\n";
- Exclude checks
Variable "content_maker" is not in valid camel caps format Open
$resource->content_maker = api_to_system_encoding($resource->content_maker, $this->encoding);
- Exclude checks
Variable "intro_text" is not in valid camel caps format Open
$resource->intro_text = api_to_system_encoding($resource->intro_text, $this->encoding);
- Exclude checks
Member variable "destination_db" is not in valid camel caps format Open
public $destination_db;
- Exclude checks
Variable "resource_to_check" is not in valid camel caps format Open
if ($resource->has_item($resource_to_check)) {
- Exclude checks
Variable "survey_question" is not in valid camel caps format Open
$resource->survey_question = api_to_system_encoding($resource->survey_question, $this->encoding);
- Exclude checks
Member variable "destination_path" is not in valid camel caps format Open
public $destination_path;
- Exclude checks
Variable "sample_text" is not in valid camel caps format Open
$sample_text = '';
- Exclude checks
Variable "survey_question_comment" is not in valid camel caps format Open
$description = $resource->survey_question_comment;
- Exclude checks
Method name "Course::to_system_encoding" is not in camel caps format Open
public function to_system_encoding()
- Exclude checks
Variable "title_qualify" is not in valid camel caps format Open
$resource->title_qualify = api_to_system_encoding($resource->title_qualify, $this->encoding);
- Exclude checks
Variable "title_qualify" is not in valid camel caps format Open
$resource->title_qualify = api_to_system_encoding($resource->title_qualify, $this->encoding);
- Exclude checks
Variable "content_license" is not in valid camel caps format Open
$resource->content_license = api_to_system_encoding($resource->content_license, $this->encoding);
- Exclude checks
Variable "resource_to_check" is not in valid camel caps format Open
if ($resource->links_to($resource_to_check)) {
- Exclude checks
Variable "content_license" is not in valid camel caps format Open
$resource->content_license = api_to_system_encoding($resource->content_license, $this->encoding);
- Exclude checks
Variable "survey_question_comment" is not in valid camel caps format Open
$resource->survey_question_comment = api_to_system_encoding($resource->survey_question_comment, $this->encoding);
- Exclude checks
Method name "Course::has_resources" is not in camel caps format Open
public function has_resources($type = null)
- Exclude checks
Variable "sample_text" is not in valid camel caps format Open
return $sample_text;
- Exclude checks
Variable "poster_name" is not in valid camel caps format Open
$resource->poster_name = api_to_system_encoding($resource->poster_name, $this->encoding);
- Exclude checks
Variable "topic_poster_name" is not in valid camel caps format Open
$resource->topic_poster_name = api_to_system_encoding($resource->topic_poster_name, $this->encoding);
- Exclude checks
Variable "survey_question" is not in valid camel caps format Open
$resource->survey_question = api_to_system_encoding($resource->survey_question, $this->encoding);
- Exclude checks
Variable "content_maker" is not in valid camel caps format Open
$resource->content_maker = api_to_system_encoding($resource->content_maker, $this->encoding);
- Exclude checks
Variable "backup_path" is not in valid camel caps format Open
$this->backup_path = '';
- Exclude checks
Missing function doc comment Open
public function show()
- Exclude checks
Variable "sample_text" is not in valid camel caps format Open
$sample_text .= $title."\n";
- Exclude checks
Variable "intro_text" is not in valid camel caps format Open
$resource->intro_text = api_to_system_encoding($resource->intro_text, $this->encoding);
- Exclude checks
The variable $sample_text is not named in camelCase. Open
public function get_sample_text()
{
$sample_text = '';
foreach ($this->resources as $type => &$resources) {
if (count($resources) > 0) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $resource_to_check is not named in camelCase. Open
public function is_linked_resource(&$resource_to_check): bool
{
foreach ($this->resources as $type => $resources) {
if (is_array($resources)) {
foreach ($resources as $resource) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $sample_text is not named in camelCase. Open
public function get_sample_text()
{
$sample_text = '';
foreach ($this->resources as $type => &$resources) {
if (count($resources) > 0) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $sample_text is not named in camelCase. Open
public function get_sample_text()
{
$sample_text = '';
foreach ($this->resources as $type => &$resources) {
if (count($resources) > 0) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $sample_text is not named in camelCase. Open
public function get_sample_text()
{
$sample_text = '';
foreach ($this->resources as $type => &$resources) {
if (count($resources) > 0) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $resource_to_check is not named in camelCase. Open
public function is_linked_resource(&$resource_to_check): bool
{
foreach ($this->resources as $type => $resources) {
if (is_array($resources)) {
foreach ($resources as $resource) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $sample_text is not named in camelCase. Open
public function get_sample_text()
{
$sample_text = '';
foreach ($this->resources as $type => &$resources) {
if (count($resources) > 0) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method is_linked_resource is not named in camelCase. Open
public function is_linked_resource(&$resource_to_check): bool
{
foreach ($this->resources as $type => $resources) {
if (is_array($resources)) {
foreach ($resources as $resource) {
- 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 get_sample_text is not named in camelCase. Open
public function get_sample_text()
{
$sample_text = '';
foreach ($this->resources as $type => &$resources) {
if (count($resources) > 0) {
- 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 add_resource is not named in camelCase. Open
public function add_resource(&$resource)
{
$this->resources[$resource->get_type()][$resource->get_id()] = $resource;
}
- 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 has_resources is not named in camelCase. Open
public function has_resources($type = null)
{
if (null != $type) {
return
isset($this->resources[$type]) && is_array($this->resources[$type]) && (
- 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 to_system_encoding is not named in camelCase. Open
public function to_system_encoding()
{
/*if (api_equal_encodings($this->encoding, api_get_system_encoding())) {
return;
}*/
- 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() {
}
}