marcelog/PAMI

View on GitHub
doc/examples/sms/example.php

Summary

Maintainability
A
0 mins
Test Coverage

The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        else{
            echo 'Unrecognized encoding - printing message in this encoding :  ' ;
            $event->getContentEncoding();
            echo '\n Message:  ' ;
            $event->getContent();
Severity: Minor
Found in doc/examples/sms/example.php by phpmd

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

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class A implements IEventListener
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

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 58 and the first side effect is on line 32.
Open

<?php
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Avoid classes with short names like A. Configured minimum length is 3.
Open

class A implements IEventListener
{
    public function handle(EventMessage $event)
    {
        //This Handler will print the incoming message.
Severity: Minor
Found in doc/examples/sms/example.php by phpmd

ShortClassName

Since: 2.9

Detects when classes or interfaces have a very short name.

Example

class Fo {

}

interface Fo {

}

Source https://phpmd.org/rules/naming.html#shortclassname

Function closing brace must go on the next line following the body; found 3 blank lines before brace
Open

    }
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Blank line found at start of control structure
Open

        if ($event->getContentEncoding()=='base64'){
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Blank line found at end of control structure
Open


Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

if ($argc <7 ) {
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Closing brace indented incorrectly; expected 8 spaces, found 12
Open

            }
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Expected 1 space after WHILE keyword; 0 found
Open

    while(true)//(time() - $time) < 60) // Wait for events.
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Expected 1 space after closing parenthesis; found 0
Open

        if ($event->getContentEncoding()=='base64'){
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Expected 1 space after closing parenthesis; found "//(time() - $time) < 60) // Wait for events.\n "
Open

    while(true)//(time() - $time) < 60) // Wait for events.
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Expected 1 space after ELSE keyword; 0 found
Open

        else{
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Expected 1 space after TRY keyword; newline found
Open

try
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

    exit (254);
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 12
Open

            }
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Closing brace indented incorrectly; expected 8 spaces, found 12
Open

            }
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Expected 1 space after closing parenthesis; found 0
Open

    if($argv[7]==1){
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 12
Open

            }
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Expected 1 space after closing brace; newline found
Open

            }
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

Expected 1 space after IF keyword; 0 found
Open

    if($argv[7]==1){
Severity: Minor
Found in doc/examples/sms/example.php by phpcodesniffer

There are no issues that match your filters.

Category
Status