Passed
Push — task/add_null_states ( 93767f )
by
unknown
11:36 queued 03:12
created

HandleOutput::handleOutput()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 5
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2.0625
1
<?php namespace App\Utilities;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
2
3
use Twig_Extension;
4
use Twig_SimpleFunction;
5
use Twig_SimpleFilter;
6
7
class HandleOutput extends Twig_Extension {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class HandleOutput
Loading history...
Coding Style introduced by
Opening brace of a class must be on the line after the definition
Loading history...
8
    /**
9
     * Functions
10
     * @return void
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
11
     */
12 16
    public function getFunctions() {
13
      return [
1 ignored issue
show
Bug Best Practice introduced by
The expression return array(new Twig_Si...this, 'handleOutput'))) returns the type array<integer,Twig_SimpleFunction> which is incompatible with the documented return type void.
Loading history...
14 16
        new Twig_SimpleFunction('handleOutput', [$this, 'handleOutput']),
15
      ];
16
    }
17
18 3
    public function handleOutput($output, $outputHtml, $nullHtml) {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function handleOutput()
Loading history...
19 3
        if( !empty($output) ) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
20 3
          echo $outputHtml;
21
        } else {
22
          echo $nullHtml;
23
        }
24 3
    }
25
}
26
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
27