http://www.phing.info/

Source Code Coverage

Designed for use with PHPUnit, Xdebug and Phing.

Methods: 5 LOC: 103 Statements: 22
Legend: executednot executeddead code
Source file Statements Methods Total coverage
Relation.php 100.0% 60.0% 92.6%
   
1
<?php
2
/**
3
 * Relation.php
4
 * 25-Apr-2011
5
 *
6
 * PHP Version 5
7
 *
8
 * @category Services
9
 * @package  Services_OpenStreetMap
10
 * @author   Ken Guest <kguest@php.net>
11
 * @license  BSD http://www.opensource.org/licenses/bsd-license.php
12
 * @version  Release: @package_version@
13
 * @link     Relation.php
14
 */
15
16
/**
17
 * Services_OpenStreetMap_Relation
18
 *
19
 * @category Services
20
 * @package  Services_OpenStreetMap
21
 * @author   Ken Guest <kguest@php.net>
22
 * @license  BSD http://www.opensource.org/licenses/bsd-license.php
23
 * @link     Relation.php
24
 */
25
class Services_OpenStreetMap_Relation extends Services_OpenStreetMap_Object
26 1
{
27
    protected $type = 'relation';
28
29
    protected $members = array();
30
31
    /**
32
     * Return all members of the relation.
33
     *
34
     * @return void
35
     */
36
    public function getMembers()
37
    {
38 3
        return $this->members;
39
    }
40
41
    /**
42
     * type
43
     *
44
     * @return string
45
     */
46
    public function getType()
47
    {
48 5
        return $this->type;
49
    }
50
51
    /**
52
     * addMember
53
     *
54
     * @todo   add member to relation
55
     * @return void
56
     */
57
    public function addMember()
58
    {
59
    }
60
61
    /**
62
     * remove a member from the relation.
63
     *
64
     * @todo   remove member from relation
65
     * @return void
66
     */
67
    public function removeMember()
68
    {
69
    }
70
71
    /**
72
     * setXml
73
     *
74
     * @param SimpleXMLElement $xml OSM XML
75
     *
76
     * @return Services_OpenStreetMap_Relation
77
     */
78
    public function setXml(SimpleXMLElement $xml)
79
    {
80 5
        $this->xml = $xml->saveXML();
81 5
        $obj = $xml->xpath('//' . $this->getType());
82 5
        foreach ($obj[0]->children() as $child) {
83 5
            $childname = $child->getName();
84 5
            if ($childname == 'tag') {
85 5
                $key = (string) $child->attributes()->k;
86 5
                if ($key != '') {
87 5
                    $this->tags[$key] = (string) $child->attributes()->v;
88 5
                }
89 5
            } elseif ($childname == 'member') {
90 5
                $this->members[] = array(
91 5
                    'type'=> (string) $child->attributes()->type,
92 5
                    'ref'=> (string) $child->attributes()->ref,
93 5
                    'role'=> (string) $child->attributes()->role,
94
                );
95
96 5
            }
97 5
        }
98 5
        $this->obj = $obj;
99 5
        return $this;
100
    }
101
}
102
// vim:set et ts=4 sw=4:
103
?>


Report generated at 2012-10-02T18:40:35+01:00