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
/**
21
 * Sub-element of <mapping>.
22
 *
23
 * @package phing.tasks.ext
24
 */
25
class PearPkgMappingElement
26
{
27
    private $key;
28
    private $value;
29
    private $elements = [];
30

31
    /**
32
     * @param $v
33
     */
34 0
    public function setKey($v)
35
    {
36 0
        $this->key = $v;
37
    }
38

39 0
    public function getKey()
40
    {
41 0
        return $this->key;
42
    }
43

44
    /**
45
     * @param $v
46
     */
47 0
    public function setValue($v)
48
    {
49 0
        $this->value = $v;
50
    }
51

52
    /**
53
     * Returns either the simple value or
54
     * the calculated value (array) of nested elements.
55
     *
56
     * @return mixed
57
     */
58 0
    public function getValue()
59
    {
60 0
        if (!empty($this->elements)) {
61 0
            $value = [];
62 0
            foreach ($this->elements as $el) {
63 0
                if ($el->getKey() !== null) {
64 0
                    $value[$el->getKey()] = $el->getValue();
65 0
                } else {
66 0
                    $value[] = $el->getValue();
67
                }
68
            }
69

70 0
            return $value;
71
        }
72

73 0
        return $this->value;
74
    }
75

76
    /**
77
     * Handles nested <element> tags.
78
     */
79 0
    public function createElement()
80
    {
81 0
        $e = new PearPkgMappingElement();
82 0
        $this->elements[] = $e;
83

84 0
        return $e;
85
    }
86
}

Read our documentation on viewing source code .

Loading