Passed
Push — task/manager-applicant-review-... ( a1a27a...d21381 )
by Xander
15:21 queued 09:20
created

HandleNullState::handleNullState()   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;
2
3
use Twig_Extension;
4
use Twig_SimpleFunction;
5
use Twig_SimpleFilter;
6
7
class HandleNullState extends Twig_Extension {
8
    /**
9
     * Functions
10
     * @return array
0 ignored issues
show
introduced by
@return annotation of method \App\Utilities\HandleNullState::getFunctions() does not specify type hint for items of its traversable return value.
Loading history...
11
     */
12 19
    public function getFunctions() {
0 ignored issues
show
introduced by
Method \App\Utilities\HandleNullState::getFunctions() does not have return type hint for its return value but it should be possible to add it based on @return annotation "array".
Loading history...
13
      return [
14 19
        new Twig_SimpleFunction('handleNullState', [$this, 'handleNullState']),
15
      ];
16
    }
17
18
    /**
19
     * This function checks if the argument is empty, if false then it will echo html for null state given, if true then return default html.
20
     * @param string|int|float|null $output
1 ignored issue
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected "string|integer|float|null" but found "string|int|float|null" for parameter type
Loading history...
21
     * @param string $outputHtml
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 16 spaces after parameter type; 1 found
Loading history...
22
     * @param string $nullStateHtml
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 16 spaces after parameter type; 1 found
Loading history...
23
     * @return void
24
     */
25 4
    public function handleNullState($output, string $outputHtml, string $nullStateHtml) {
0 ignored issues
show
introduced by
Method \App\Utilities\HandleNullState::handleNullState() does not have return type hint for its return value but it should be possible to add it based on @return annotation "void".
Loading history...
26 4
        if (!empty($output)) {
27 4
          echo $outputHtml;
28
        } else {
29
          echo $nullStateHtml;
30
        }
31 4
    }
32
  }
0 ignored issues
show
Coding Style introduced by
Closing brace indented incorrectly; expected 0 spaces, found 2
Loading history...
33