Changeset 1787
- Timestamp:
- 08/27/08 14:27:24 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
framework/trunk/src/main/php/net/stubbles/peer/http/stubHTTPURL.php
r1763 r1787 1 1 <?php 2 2 /** 3 * Class for URLs of hypertext transfer protocol.3 * Class for URLs of scheme hypertext transfer protocol. 4 4 * 5 5 * @author Frank Kleine <mikey@stubbles.net> … … 7 7 * @subpackage peer_http 8 8 */ 9 stubClassLoader::load('net::stubbles::lang::exceptions::stubIllegalArgumentException', 10 'net::stubbles::peer::stubURL' 11 ); 9 stubClassLoader::load('net::stubbles::peer::stubURL'); 12 10 /** 13 * Class for URLs of hypertext transfer protocol.11 * Class for URLs of scheme hypertext transfer protocol. 14 12 * 15 13 * @package stubbles … … 73 71 74 72 return true; 75 }76 77 /**78 * add a parameter to the url79 *80 * @param string $key name of parameter81 * @param mixed $value value of parameter82 * @throws stubIllegalArgumentException83 */84 public function addParam($key, $value)85 {86 if (is_string($key) == false) {87 throw new stubIllegalArgumentException('Argument 1 passed to ' . __METHOD__ . '() must be an instance of string.');88 }89 90 if (null !== $value && is_array($value) == false && is_scalar($value) == false) {91 throw new stubIllegalArgumentException('Argument 2 passed to ' . __METHOD__ . '() must be an instance of string, array or any other scalar value or null.');92 }93 94 if (null === $value and isset($this->params[$key]) == true) {95 unset($this->params[$key]);96 } elseif (null !== $value) {97 if (false === $value) {98 $value = 0;99 } elseif (true === $value) {100 $value = 1;101 }102 103 $this->params[$key] = $value;104 }105 73 } 106 74 framework/trunk/src/main/php/net/stubbles/peer/stubURL.php
r1763 r1787 7 7 * @subpackage peer_net 8 8 */ 9 stubClassLoader::load('net::stubbles::peer::stubMalformedURLException'); 9 stubClassLoader::load('net::stubbles::lang::exceptions::stubIllegalArgumentException', 10 'net::stubbles::peer::stubMalformedURLException', 11 'net::stubbles::peer::stubURLContainer' 12 ); 10 13 /** 11 14 * Class for URLs and methods on URLs. … … 14 17 * @subpackage peer_net 15 18 */ 16 class stubURL extends stubBaseObject 19 class stubURL extends stubBaseObject implements stubURLContainer 17 20 { 18 21 /** … … 252 255 253 256 /** 257 * sets the port 258 * 259 * @param int $port 260 */ 261 public function setPort($port) 262 { 263 $this->url['port'] = $port; 264 } 265 266 /** 254 267 * returns port of the url 255 268 * … … 267 280 268 281 /** 269 * sets the port270 *271 * @param int $port272 */273 public function setPort($port)274 {275 $this->url['port'] = $port;276 }277 278 /**279 282 * returns path of the url 280 283 * … … 302 305 { 303 306 return (isset($this->url['query']) === true && strlen($this->url['query']) > 0); 307 } 308 309 /** 310 * add a parameter to the url 311 * 312 * @param string $key name of parameter 313 * @param mixed $value value of parameter 314 * @throws stubIllegalArgumentException 315 */ 316 public function addParam($key, $value) 317 { 318 if (is_string($key) == false) { 319 throw new stubIllegalArgumentException('Argument 1 passed to ' . __METHOD__ . '() must be an instance of string.'); 320 } 321 322 if (null !== $value && is_array($value) == false && is_scalar($value) == false) { 323 throw new stubIllegalArgumentException('Argument 2 passed to ' . __METHOD__ . '() must be an instance of string, array or any other scalar value or null.'); 324 } 325 326 if (null === $value and isset($this->params[$key]) == true) { 327 unset($this->params[$key]); 328 } elseif (null !== $value) { 329 if (false === $value) { 330 $value = 0; 331 } elseif (true === $value) { 332 $value = 1; 333 } 334 335 $this->params[$key] = $value; 336 } 304 337 } 305 338
