Relation.php
Current file: /home/kguest/dev/code/Services_Openstreetmap/Services/Openstreetmap/Relation.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00% 0 / 1
40.00% 2 / 5 CRAP
86.36% 19 / 22
Services_Openstreetmap_Relation
0.00% 0 / 1
40.00% 2 / 5 9.21
86.36% 19 / 22
 getMembers()
0.00% 0 / 1 2
0.00% 0 / 1
 getType()
100.00% 1 / 1 1
100.00% 1 / 1
 addMember()
0.00% 0 / 1 2
0.00% 0 / 1
 removeMember()
0.00% 0 / 1 2
0.00% 0 / 1
 setXml(SimpleXMLElement $xml)
100.00% 1 / 1 5
100.00% 18 / 18


       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                 : {                                                                          
      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               0 :         return $this->members;                                             
      39                 :     }                                                                      
      40                 :                                                                            
      41                 :     /**                                                                    
      42                 :      * type                                                                
      43                 :      *                                                                     
      44                 :      * @return string                                                      
      45                 :      */                                                                    
      46                 :     public function getType()                                              
      47                 :     {                                                                      
      48               1 :         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               0 :     }                                                                      
      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               0 :     }                                                                      
      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               1 :         $this->xml = $xml->saveXML();                                      
      81               1 :         $obj = $xml->xpath('//' . $this->getType());                       
      82               1 :         foreach ($obj[0]->children() as $child) {                          
      83               1 :             $childname = $child->getName();                                
      84               1 :             if ($childname == 'tag') {                                     
      85               1 :                 $key = (string) $child->attributes()->k;                   
      86               1 :                 if ($key != '') {                                          
      87               1 :                     $this->tags[$key] = (string) $child->attributes()->v;  
      88               1 :                 }                                                          
      89               1 :             } elseif ($childname == 'member') {                            
      90               1 :                 $this->members[] = array(                                  
      91               1 :                     'type'=> (string) $child->attributes()->type,          
      92               1 :                     'ref'=> (string) $child->attributes()->ref,            
      93               1 :                     'role'=> (string) $child->attributes()->role,          
      94                 :                 );                                                         
      95                 :                                                                            
      96               1 :             }                                                              
      97               1 :         }                                                                  
      98               1 :         $this->obj = $obj;                                                 
      99               1 :         return $this;                                                      
     100                 :     }                                                                      
     101                 : }                                                                          
     102                 : // vim:set et ts=4 sw=4:                                                   
     103                 : ?>                                                                         

Generated by PHP_CodeCoverage 1.1.1 using PHP 5.3.8 and PHPUnit 3.6.7 at Sat Feb 4 0:05:01 GMT 2012.