Passed
Pull Request — master (#195)
by
unknown
07:40
created

GetStatusColorViewHelper::render()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 31
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 23
c 1
b 0
f 0
nc 7
nop 1
dl 0
loc 31
rs 8.6186
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 \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
20
{
21
    /**
22
     * Gets the related color for alias states.
23
     *
24
     * @param string $status
25
     * @return string
26
     */
27
    public function render($status)
28
    {
29
       $aliasState = DocumentWorkflow::getAliasStateByLocalOrRepositoryState($status);
30
31
       switch ($aliasState) {
32
33
           case DocumentWorkflow::ALIAS_STATE_NEW:
34
               return 'secondary';
35
               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...
36
           case DocumentWorkflow::ALIAS_STATE_REGISTERED:
37
               return 'secondary';
38
               break;
39
40
           case DocumentWorkflow::ALIAS_STATE_IN_PROGRESS:
41
               return 'primary';
42
               break;
43
44
           case DocumentWorkflow::ALIAS_STATE_RELEASED:
45
               return 'success';
46
               break;
47
48
           case DocumentWorkflow::ALIAS_STATE_DISCARDED:
49
               return 'warning';
50
               break;
51
52
           case DocumentWorkflow::ALIAS_STATE_POSTPONED:
53
               return 'info';
54
               break;
55
           default:
56
               return 'light';
57
               break;
58
       }
59
    }
60
}
61