Aggregate Code Coverage for all tests
1 : <?php 2 : /** 3 : * PEAR2_Pyrus_PackageFile_v2_License 4 : * 5 : * PHP version 5 6 : * 7 : * @category PEAR2 8 : * @package PEAR2_Pyrus 9 : * @author Greg Beaver <cellog@php.net> 10 : * @copyright 2008 The PEAR Group 11 : * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 12 : * @version SVN: $Id$ 13 : * @link http://svn.pear.php.net/wsvn/PEARSVN/Pyrus/ 14 : */ 15 : 16 : /** 17 : * Represents the files within a package file 18 : * 19 : * @category PEAR2 20 : * @package PEAR2_Pyrus 21 : * @author Greg Beaver <cellog@php.net> 22 : * @copyright 2008 The PEAR Group 23 : * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 24 : * @link http://svn.pear.php.net/wsvn/PEARSVN/Pyrus/ 25 : */ 26 1 : class PEAR2_Pyrus_PackageFile_v2_License implements ArrayAccess 27 : { 28 : protected $array; 29 : function __construct(&$array) 30 : { 31 1 : $this->array = &$array; 32 1 : } 33 : 34 : function link(&$array) 35 : { 36 : $null = 1; 37 : $this->array = &$null; 38 : $this->array = &$array; 39 : } 40 : 41 : function getArray() 42 : { 43 : $arr = $this->array; 44 : return $arr; 45 : } 46 : function offsetUnset($var) 47 : { 48 : if ($var == 'name') { 49 : if (isset($this->array['_content'])) { 50 : unset($this->array['_content']); 51 : } elseif (isset($this->array[0])) { 52 : unset($this->array[0]); 53 : } 54 : return; 55 : } 56 : if ($var == 'uri') { 57 : unset($this->array['attribs']['uri']); 58 : if (!count($this->array['attribs'])) { 59 : unset($this->array['attribs']); 60 : if (isset($this->array['_content'])) { 61 : $this->array[0] = $this->array['_content']; 62 : unset($this->array['_content']); 63 : } 64 : } 65 : return; 66 : } 67 : if ($var == 'path') { 68 : unset($this->array['attribs']['path']); 69 : if (!count($this->array['attribs'])) { 70 : unset($this->array['attribs']); 71 : if (isset($this->array['_content'])) { 72 : $this->array[0] = $this->array['_content']; 73 : unset($this->array['_content']); 74 : } 75 : } 76 : return; 77 : } 78 : } 79 : 80 : function offsetGet($var) 81 : { 82 1 : if ($var == 'uri') { 83 1 : if (isset($this->array['attribs']) && isset($this->array['attribs']['uri'])) { 84 1 : return $this->array['attribs']['uri']; 85 : } 86 : return null; 87 : } 88 1 : if ($var == 'path') { 89 1 : if (isset($this->array['attribs']) && isset($this->array['attribs']['path'])) { 90 : return $this->array['attribs']['path']; 91 : } 92 1 : return null; 93 : } 94 1 : if ($var == 'name') { 95 1 : if (isset($this->array['_content'])) { 96 1 : return $this->array['_content']; 97 : } 98 : if (isset($this->array[0])) { 99 : return $this->array[0]; 100 : } 101 : } 102 : return null; 103 : } 104 : 105 : function offsetSet($var, $value) 106 : { 107 : if (!is_string($value)) { 108 : throw new PEAR2_Pyrus_PackageFile_v2_License_Exception('Can only set license to string'); 109 : } 110 : 111 : if ($var == 'path' || $var == 'uri') { 112 : if (!isset($this->array['attribs'])) { 113 : if (isset($this->array[0])) { 114 : $this->array['_content'] = $this->array[0]; 115 : unset($this->array[0]); 116 : } 117 : $this->array['attribs'] = array(); 118 : } 119 : } else { 120 : if ($var == 'name') { 121 : if (!isset($this->array['attribs'])) { 122 : $this->array[0] = $value; 123 : return; 124 : } 125 : $this->array['_content'] = $value; 126 : return; 127 : } 128 : throw new PEAR2_Pyrus_PackageFile_v2_License_Exception('Unknown license trait ' . $var . ', cannot set value'); 129 : } 130 : $this->array['attribs'][$var] = $value; 131 : } 132 : 133 : function offsetExists($var) 134 : { 135 : if ($var == 'uri') { 136 : return isset($this->array['attribs']) && isset($this->array['attribs']['uri']); 137 : } 138 : if ($var == 'path') { 139 : return isset($this->array['attribs']) && isset($this->array['attribs']['path']); 140 : } 141 : if ($var == 'name') { 142 : return (isset($this->array['attribs']) && isset($this->array['_content'])) || 143 : isset($this->array[0]); 144 : } 145 : return false; 146 : } 147 1 : }