Passed
Push — master ( 19f06a...8d1e35 )
by Ralf
24:17
created

GetStatusColorViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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
use EWW\Dpf\Domain\Workflow\DocumentWorkflow;
18
19
class GetStatusColorViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper
20
{
21
    public function initializeArguments()
22
    {
23
        parent::initializeArguments();
24
25
        $this->registerArgument('status', 'string', '', true);
26
    }
27
28
    /**
29
     * Gets the related color for alias states.
30
     *
31
     * @return string
32
     */
33
    public function render()
34
    {
35
        $status = $this->arguments['status'];
36
37
        $aliasState = DocumentWorkflow::getAliasStateByLocalOrRepositoryState($status);
38
39
        switch ($aliasState) {
40
41
           case DocumentWorkflow::ALIAS_STATE_NEW:
42
               return 'secondary';
43
               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...
44
           case DocumentWorkflow::ALIAS_STATE_REGISTERED:
45
               return 'secondary';
46
               break;
47
48
           case DocumentWorkflow::ALIAS_STATE_IN_PROGRESS:
49
               return 'primary';
50
               break;
51
52
           case DocumentWorkflow::ALIAS_STATE_RELEASED:
53
               return 'success';
54
               break;
55
56
           case DocumentWorkflow::ALIAS_STATE_DISCARDED:
57
               return 'warning';
58
               break;
59
60
           case DocumentWorkflow::ALIAS_STATE_POSTPONED:
61
               return 'info';
62
               break;
63
           default:
64
               return 'light';
65
               break;
66
        }
67
    }
68
}
69