Options   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 17.24 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 10
loc 58
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setData() 10 10 2
B initDefaultOptionItems() 0 26 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Copyright © 2017 Toan Nguyen. All rights reserved.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Gojira\Framework\App\Configuration;
10
11
use Gojira\Framework\Data\DataObject;
12
13
/**
14
 * Base class to work with option items
15
 *
16
 * @package Gojira\Framework\App\Configuration
17
 * @author  Toan Nguyen <[email protected]>
18
 */
19
class Options extends DataObject implements OptionsInterface
20
{
21
    /**
22
     * Overwrite data in the object.
23
     *
24
     * The $key parameter can be string or array.
25
     * If $key is string, the attribute value will be overwritten by $value
26
     *
27
     * If $key is an array, it will overwrite all the data in the object.
28
     *
29
     * @param string|array $key
30
     * @param mixed        $value
31
     *
32
     * @return $this
33
     */
34 View Code Duplication
    public function setData($key, $value = null)
35
    {
36
        if ($key === (array)$key) {
37
            $this->_data = $key;
38
        } else {
39
            $this->_data[$key] = $value;
40
        }
41
42
        return $this;
43
    }
44
45
    /**
46
     * Init default option items
47
     *
48
     * @return array
49
     */
50
    public function initDefaultOptionItems()
51
    {
52
        return [
53
            self::JIRA_STOP        => [
54
                self::STATUS => 'To Do'
55
            ],
56
            self::JIRA_START       => [
57
                self::STATUS => 'In Progress'
58
            ],
59
            self::JIRA_REVIEW      => [
60
                self::STATUS => 'In Review'
61
            ],
62
            self::JIRA_DONE        => [
63
                self::STATUS => 'Done'
64
            ],
65
            self::AVAILABLE_ISSUES => [
66
                'Open',
67
                'In Progress',
68
                'Reopened',
69
                'To Do',
70
                'In Review',
71
                'Blocked',
72
                'Internal Testing'
73
            ]
74
        ];
75
    }
76
}
77