Passed
Push — master ( a862c8...fef60d )
by Siad
05:54
created

AbstractPropertySetterTask   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 95%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 36
ccs 19
cts 20
cp 0.95
rs 10
c 0
b 0
f 0
wmc 8

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setOverride() 0 3 1
A setProperty() 0 3 1
A validate() 0 4 2
A setPropertyValue() 0 14 4
1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19
20
abstract class AbstractPropertySetterTask extends Task
21
{
22
    private $property;
23
    private $override = false;
24
25 1
    public function setOverride($override)
26
    {
27 1
        $this->override = $override;
28 1
    }
29
30 10
    public function setProperty($property)
31
    {
32 10
        $this->property = $property;
33 10
    }
34
35 7
    protected function validate()
36
    {
37 7
        if ($this->property == null) {
38
            throw new BuildException("You must specify a property to set.");
39
        }
40 7
    }
41
42 10
    protected function setPropertyValue($value)
43
    {
44 10
        if ($value !== null) {
45 10
            if ($this->override) {
46 1
                if ($this->getProject()->getUserProperty($this->property) == null) {
47 1
                    $this->getProject()->setProperty($this->property, $value);
48
                } else {
49 1
                    $this->getProject()->setUserProperty($this->property, $value);
50
                }
51
            } else {
52 9
                $p = $this->project->createTask("property");
53 9
                $p->setName($this->property);
0 ignored issues
show
Bug introduced by
The method setName() does not exist on Task. It seems like you code against a sub-type of Task such as TaskdefTask or RecorderTask or GrowlNotifyTask or PackageAsPathTask or TypedefTask or PropertyTask or Phing\Tasks\Ext\PhkPackageTask or PathToFileSet or AdhocTypedefTask or AdhocTaskdefTask or GitTagTask or HgTagTask or StopwatchTask. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
                $p->/** @scrutinizer ignore-call */ 
54
                    setName($this->property);
Loading history...
54 9
                $p->setValue($value);
0 ignored issues
show
Bug introduced by
The method setValue() does not exist on Task. It seems like you code against a sub-type of Task such as UpToDateTask or AvailableTask or SwitchTask or PropertyTask or CaseTask or URLEncodeTask or SortList. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
                $p->/** @scrutinizer ignore-call */ 
55
                    setValue($value);
Loading history...
55 9
                $p->main();
56
            }
57
        }
58 10
    }
59
}
60