Skip to content

Instantly share code, notes, and snippets.

@aholmes
Last active January 3, 2016 17:59
Show Gist options
  • Save aholmes/8498916 to your computer and use it in GitHub Desktop.
Save aholmes/8498916 to your computer and use it in GitHub Desktop.
<?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