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
 * Handles complex options <mapping> elements which are hashes (assoc arrays).
22
 *
23
 * @package phing.tasks.ext
24
 */
25
class PearPkgMapping
26
{
27
    private $name;
28
    private $elements = [];
29

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

38 0
    public function getName()
39
    {
40 0
        return $this->name;
41
    }
42

43
    /**
44
     * @return PearPkgMappingElement
45
     */
46 0
    public function createElement()
47
    {
48 0
        $e = new PearPkgMappingElement();
49 0
        $this->elements[] = $e;
50

51 0
        return $e;
52
    }
53

54
    /**
55
     * @return array
56
     */
57 0
    public function getElements()
58
    {
59 0
        return $this->elements;
60
    }
61

62
    /**
63
     * Returns the PHP hash or array of hashes (etc.) that this mapping represents.
64
     *
65
     * @return array
66
     */
67 0
    public function getValue()
68
    {
69 0
        $value = [];
70 0
        foreach ($this->getElements() as $el) {
71 0
            if ($el->getKey() !== null) {
72 0
                $value[$el->getKey()] = $el->getValue();
73 0
            } else {
74 0
                $value[] = $el->getValue();
75
            }
76
        }
77

78 0
        return $value;
79
    }
80
}

Read our documentation on viewing source code .

Loading