Last active
January 3, 2016 17:59
-
-
Save aholmes/8498916 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class HTTP { | |
protected _statusCode; | |
protected function _getStatusCode() { | |
return $this._statusCode; | |
} | |
protected _url; | |
protected function _getUrl() { | |
return $this->_url; | |
} | |
protected function _setUrl($value) { | |
if (!filter_var($url, FILTER_VALIDATE_URL)) throw new Exception('Invalid URL "' + $value + '"'); | |
$this->_url = $value; | |
} | |
public function __get($name) { | |
switch($name) { | |
case 'statusCode': | |
return $this->_getStatusCode(); | |
break; | |
case 'url': | |
return $this->getUrl(); | |
break; | |
default: | |
throw new Exception('Can\'t get property "' + $name + '." It does not exist.'); | |
} | |
} | |
public function __set($name, $value) { | |
switch($name) { | |
case 'url': | |
$this->setUrl($value); | |
break; | |
default: | |
throw new Exception('Can\'t set property "' + $name + '." It does not exist.'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment