Passed
Pull Request — master (#135)
by
unknown
07:45
created

ShowStateViewHelper::render()   B

Complexity

Conditions 9
Paths 9

Size

Total Lines 28
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 22
nc 9
nop 1
dl 0
loc 28
rs 8.0555
c 0
b 0
f 0
1
<?php
2
namespace EWW\Dpf\ViewHelpers;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
class ShowStateViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
18
{
19
20
    /**
21
     *
22
     * @param string $state
23
     *
24
     */
25
    public function render($state)
26
    {
27
28
        $key = "";
29
30
        switch ($state) {
31
            case \EWW\Dpf\Domain\Model\Document::OBJECT_STATE_NEW:
32
                $key = 'search.resultList.state.new';
33
                break;
34
            case \EWW\Dpf\Domain\Model\Document::OBJECT_STATE_ACTIVE:
35
            case 'A':
36
                $key = 'search.resultList.state.active';
37
                break;
38
            case \EWW\Dpf\Domain\Model\Document::OBJECT_STATE_INACTIVE:
39
            case 'I':
40
                $key = 'search.resultList.state.inactive';
41
                break;
42
            case \EWW\Dpf\Domain\Model\Document::OBJECT_STATE_DELETED:
43
            case \EWW\Dpf\Domain\Model\Document::OBJECT_STATE_LOCALLY_DELETED:
44
            case 'D':
45
                $key = 'search.resultList.state.deleted';
46
                break;
47
            default:
48
                return "-";
49
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
50
        }
51
52
        return \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, 'dpf', $arguments = null);
53
    }
54
}
55