Passed
Push — main ( 28d658...6dddcc )
by Michiel
06:12
created

PhpDependAnalyzerElement::setValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 10
ccs 0
cts 7
cp 0
rs 10
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
/**
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the LGPL. For more information please see
18
 * <http://phing.info>.
19
 */
20
21
namespace Phing\Task\Ext\Analyzer\Pdepend;
22
23
use Phing\Exception\BuildException;
24
25
/**
26
 * Analyzer element for the PhpDependTask
27
 *
28
 * @package phing.tasks.ext.pdepend
29
 * @author  Benjamin Schultz <[email protected]>
30
 * @since   2.4.1
31
 */
32
class PhpDependAnalyzerElement
33
{
34
    /**
35
     * The type of the analyzer
36
     *
37
     * @var string
38
     */
39
    protected $type = '';
40
41
    /**
42
     * The value(s) for the analyzer option
43
     *
44
     * @var array
45
     */
46
    protected $value = [];
47
48
    /**
49
     * Sets the analyzer type
50
     *
51
     * @param string $type Type of the analyzer
52
     *
53
     * @throws BuildException
54
     */
55
    public function setType($type)
56
    {
57
        $this->type = $type;
58
59
        switch ($this->type) {
60
            case 'coderank-mode':
61
                break;
62
63
            default:
64
                throw new BuildException('Analyzer "' . $this->type . '" not implemented');
65
        }
66
    }
67
68
    /**
69
     * Get the analyzer type
70
     *
71
     * @return string
72
     */
73
    public function getType()
74
    {
75
        return $this->type;
76
    }
77
78
    /**
79
     * Sets the value for the analyzer
80
     *
81
     * @param string $value Value for the analyzer
82
     */
83
    public function setValue($value)
84
    {
85
        $this->value = [];
86
87
        $token = ' ,;';
88
        $values = strtok($value, $token);
89
90
        while ($values !== false) {
91
            $this->value[] = $values;
92
            $values = strtok($token);
93
        }
94
    }
95
96
    /**
97
     * Get the analyzer value
98
     *
99
     * @return string
100
     */
101
    public function getValue()
102
    {
103
        return $this->value;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->value returns the type array which is incompatible with the documented return type string.
Loading history...
104
    }
105
}
106