Passed
Push — feature/job_api_route ( a33aa1...9319dc )
by Tristan
10:55
created

HandleNullState::handleNullState()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 3
crap 3
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
    /**
10
     * Functions
11
     * @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...
12
     */
13 19
    public function getFunctions(): array
14
    {
15
        return [
16 19
          new Twig_SimpleFunction('handleNullState', [$this, 'handleNullState']),
17
        ];
18
    }
19
20
    /**
21
     * This function checks if the argument is empty, if false then it will echo html for null state given,
22
     * if true then return default html.
23
     *
24
     * @param string|integer|float|null $output
1 ignored issue
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
25
     * @param string|null               $outputHtml
1 ignored issue
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
26
     * @param string                    $nullStateHtml
1 ignored issue
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
27
     *
28
     * @return void
29
     */
30 4
    public function handleNullState($output, $outputHtml, string $nullStateHtml): void
31
    {
32 4
        if (!empty($output) && !empty($outputHtml)) {
33 4
            echo $outputHtml;
34
        } else {
35 2
            echo $nullStateHtml;
36
        }
37 4
    }
38
}
39