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

HandleNullState   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 29
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 4 1
A handleNullState() 0 6 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