diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b64254 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Pingdom PHP Api + +## Install + +### Composer +In your composer.json add the following in your require statement + +```` +'dixcart/php-pingdom': 'dev-master' +```` + +## Basic usage + +```` +require 'vendor/autoload.php'; +$api = new \Pingdom\Api(USERNAME, PASSWORD); +try { + $response = $api->getChecks(); + echo json_encode($response); +} catch (\Exception $e) { + echo json_encode(array('error' => $e->getMessage)); +} \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..70bbb60 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "dixcart/php-pingdom", + "type": "library", + "description": "PHP Pingdom Api", + "keywords": ["pingdom"], + "authors": [ + { + "name": "Surrey Business IT" + } + ], + "require": { + "php": ">=5.3.3" + }, + "autoload": { + "psr-0": { + "": "src/" + } + } +} \ No newline at end of file diff --git a/examples/getChecksAsJSON.php b/examples/getChecksAsJSON.php deleted file mode 100644 index c964fa7..0000000 --- a/examples/getChecksAsJSON.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @link http://github.com/dixcart/php-pingdom - * @link http://dixcart.com/it - * @version 1 - * @license bsd - */ -/** - * Returns a list of all checks on an account as a JSON string - * - * @package php-pingdom - * @subpackage examples - */ - -DEFINE('PINGDOM_USR', 'username@email.com'); -DEFINE('PINGDOM_PWD', 'MyReallyStrongPassword'); - -require_once dirname(__FILE__).'/../src/Pingdom/Autoload.php'; -Pingdom_Autoload::register(); - -$api = new Pingdom_API(PINGDOM_USR, PINGDOM_PWD); -try { - $resp = $api->getChecks(); - echo json_encode($resp); -} catch (Exception $e) { - echo "{ error: \"" . $e->getMessage() . "}"; -} -?> diff --git a/src/Pingdom/API.php b/src/Pingdom/API.php deleted file mode 100644 index a58a9d1..0000000 --- a/src/Pingdom/API.php +++ /dev/null @@ -1,244 +0,0 @@ - - * @link http://github.com/dixcart/php-pingdom - * @link http://dixcart.com/it - * @version 1 - * @license bsd - */ - -class Pingdom_API { - - const METHOD_GET = 1; - const METHOD_POST = 2; - const METHOD_DELETE = 3; - const METHOD_PUT = 4; - - const APP_KEY = "rbh7purydqixtjn7ngpyxrjwjr4sqnna"; - const API_ADDR = "https://api.pingdom.com/api/2.0"; - - private $_apiUser; - private $_apiPass; - private $_acceptGzip; - private $_lastResponse; - private $_lastStatus; - - function __construct($apiUser, $apiPass, $acceptGzip = true) - { - if(!$apiUser || !$apiPass) { - throw new Exception('Username/Password required'); - } - - $this->_apiUser = $apiUser; - $this->_apiPass = $apiPass; - $this->_acceptGzip = $acceptGzip; - } - - function _doRequest($path, $data = null, $method = null) - { - $return = ""; - $curl = curl_init(); - - //Set up curl and authentication - curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($curl, CURLOPT_USERPWD, $this->_apiUser.":".$this->_apiPass); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - - - //Set app-key header - $headers = array( - sprintf("%s: %s", "App-Key", self::APP_KEY) - ); - - //Enable GZip encoding - if ($this->_acceptGzip) curl_setopt($curl, CURLOPT_ENCODING, "gzip"); - - //Set URL - curl_setopt($curl, CURLOPT_URL, self::API_ADDR.$path); - - - switch($method) { - case self::METHOD_POST: - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $data); - break; - case self::METHOD_DELETE: - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); - break; - case self::METHOD_PUT: - curl_setopt($curl, CURLOPT_PUT, true); - $putData = tmpfile(); - fwrite($putData, $data); - fseek($putData, 0); - curl_setopt($curl, CURLOPT_INFILE, $putData); - curl_setopt($curl, CURLOPT_INFILESIZE, strlen($data)); - break; - default: - break; - } - - //Set headers - curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - - //Send the request - $this->_lastResponse = curl_exec($curl); - - //If it was a PUT we need to close the tmpfile - if ($method == self::METHOD_PUT) fclose($putData); - - //Handle response and status codes - $curlinfo = curl_getinfo($curl); - if (!empty($curlinfo["http_code"])) { - $this->_lastStatus = $curlinfo["http_code"]; - switch ($this->_lastStatus) { - case '200': - //All ok - $return = json_decode($this->_lastResponse, true); - break; - case '404': - throw new Exception('URL not found'); - break; - case '500': - throw new Exception('Remote server reported an Internal Server Error'); - break; - default: - //There was an error - $err = json_decode($this->_lastResponse, true); - throw new Exception('There was an error: ' . $err['error']['statuscode'] . " - " . $err['error']['statusdesc'] . ": " . $err['error']['errormessage']); - break; - } - } - - //Clean up - curl_close($curl); - return $return; - } - - /** - * Returns a list of actions(alerts) that have been generated for your account - * - * @param int $limit number of results to return (default=100, max = 300) - * @param int $offset offset for listing (requires limit to be set) - * @param int $from Unix timestamp to count checks from - * @param int $to Unix timestamp to count checks up to - * @param string $checkIds comma separated list of check IDs - * @param string $contactIds comma separated list of contact IDs - * @param string $status comma separated list of statuses - * @param string $via comma separated list of methods alerts were sent to - */ - public function getActions($limit = 100, $offset = 0, $from = null, $to = null, $checkIds = null, $contactIds = null, $status = null, $via = null) - { - if ($offset > 25000) throw new Exception('Limit set too high'); - - $url = "/actions/?limit=" . $limit . "&offset=" . $offset; - if ($from != null) $usr += "&from=" . $from; - if ($to != null) $usr += "&to=" . $to; - if ($checkIds != null) $usr += "&checkids=" . $checkIds; - if ($contactIds != null) $usr += "&contactids=" . $contactIds; - if ($status != null) $usr += "&status=" . $status; - if ($via != null) $usr += "&via=" . $via; - - return $this->_doRequest($url); - } - - /** - * Returns a list of the latest error analysis results for a specified check - * - * @param int $checkId The check ID to get analysis for - * @param int $limit number of results to return (default = 100) - * @param int $offset offset for listing - */ - public function getError($checkId, $limit = 100, $offset = 0) - { - $url = "/analysis/" . $checkId . "/?limit=" . $limit . "&offset=" . $offset; - return $this->_doRequest($url); - } - - /** - * Returns the raw result for a specified error analysis. This data is primarily intended for internal - * use, but you might be interested in it as well. However, there is no real documentation for this - * data at the moment. In the future, we may add a new API method that provides a more user-friendly format. - * - * @param int $checkId ID of the check - * @param int $analysisId ID of the analysis - */ - public function getRawAnalysis($checkId, $analysisId) - { - $url = "/analysis/" . $checkId . "/" . $analysisId; - return $this->_doRequest($url); - } - - /** - * Gets a list of all checks on the account - * - * @param int $limit number of results to return (default=500, max = 25000) - * @param int $offset offset for listing (requires limit to be set) - * @return array JSON response encoded to array - */ - public function getChecks($limit = 500, $offset = 0) - { - if ($offset > 25000) throw new Exception('Limit set too high'); - - $url = "/checks/?limit=" . $limit . "&offset=" . $offset; - return $this->_doRequest($url); - } - - public function getProbes($limit = 500, $offset = 0, $onlyactive="false") - { - if ($offset > 25000) throw new Exception('Limit set too high'); - $url = "/probes?limit=" . $limit . "&offset=" . $offset. "&onlyactive=" . $onlyactive; - return $this->_doRequest($url); - } - - public function getTraceroute($target, $probeid = 0) - { - $url = "/traceroute". "?host=" . $target. "&probeid=" . $probeid; - return $this->_doRequest($url); - } - - - /** - * Returns a detailed description of a specified check - * - * @param int $checkId the ID of the check you wish to get more detail on (see getChecks) - * @return array JSON response encoded to array - */ - public function getCheck($checkId) - { - $url = "/checks/" . $checkId; - return $this->_doRequest($url); - - } - - /** - * Internal function to handle adding all types of check, assumes other functions - * have validated the data - * - * @param Pingdom_Check $check Check object to insert - * @return string JSON string of result - */ - public function addCheck($check) - { - $url = "/checks"; - $postData = $check->_prepData(); - return $this->_doRequest($url, $postData, self::METHOD_POST); - } -} diff --git a/src/Pingdom/Api.php b/src/Pingdom/Api.php new file mode 100644 index 0000000..0c11ca8 --- /dev/null +++ b/src/Pingdom/Api.php @@ -0,0 +1,252 @@ + + * @link http://github.com/dixcart/php-pingdom + * @link http://dixcart.com/it + * @version 1 + * @license bsd + */ +namespace Pingdom; + +class Api +{ + + const METHOD_GET = 1; + const METHOD_POST = 2; + const METHOD_DELETE = 3; + const METHOD_PUT = 4; + + const APP_KEY = "rbh7purydqixtjn7ngpyxrjwjr4sqnna"; + const API_ADDR = "https://api.pingdom.com/api/2.0"; + + private $_apiUser; + private $_apiPass; + private $_acceptGzip; + private $_lastResponse; + private $_lastStatus; + + function __construct($apiUser, $apiPass, $acceptGzip = true) + { + if (!$apiUser || !$apiPass) { + throw new \Exception('Username/Password required'); + } + + $this->_apiUser = $apiUser; + $this->_apiPass = $apiPass; + $this->_acceptGzip = $acceptGzip; + } + + function _doRequest($path, $data = null, $method = null) + { + $return = ""; + $curl = curl_init(); + + //Set up curl and authentication + curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($curl, CURLOPT_USERPWD, $this->_apiUser . ":" . $this->_apiPass); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + + //Set app-key header + $headers = array( + sprintf("%s: %s", "App-Key", self::APP_KEY) + ); + + //Enable GZip encoding + if ($this->_acceptGzip) curl_setopt($curl, CURLOPT_ENCODING, "gzip"); + + //Set URL + curl_setopt($curl, CURLOPT_URL, self::API_ADDR . $path); + + $putData = ''; + switch ($method) { + case self::METHOD_POST: + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + break; + case self::METHOD_DELETE: + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); + break; + case self::METHOD_PUT: + curl_setopt($curl, CURLOPT_PUT, true); + $putData = tmpfile(); + fwrite($putData, $data); + fseek($putData, 0); + curl_setopt($curl, CURLOPT_INFILE, $putData); + curl_setopt($curl, CURLOPT_INFILESIZE, strlen($data)); + break; + default: + break; + } + + //Set headers + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + //Send the request + $this->_lastResponse = curl_exec($curl); + + //If it was a PUT we need to close the tmpfile + if ($method == self::METHOD_PUT) { + fclose($putData); + } + + //Handle response and status codes + $curlinfo = curl_getinfo($curl); + if (!empty($curlinfo["http_code"])) { + $this->_lastStatus = $curlinfo["http_code"]; + switch ($this->_lastStatus) { + case '200': + //All ok + $return = json_decode($this->_lastResponse, true); + break; + case '404': + throw new \Exception('URL not found'); + break; + case '500': + throw new \Exception('Remote server reported an Internal Server Error'); + break; + default: + //There was an error + $err = json_decode($this->_lastResponse, true); + throw new \Exception('There was an error: ' . $err['error']['statuscode'] . " - " . $err['error']['statusdesc'] . ": " . $err['error']['errormessage']); + break; + } + } + + //Clean up + curl_close($curl); + return $return; + } + + /** + * Returns a list of actions(alerts) that have been generated for your account + * + * @param int $limit : number of results to return (default=100, max = 300) + * @param int $offset : offset for listing (requires limit to be set) + * @param null|int $from : Unix timestamp to count checks from + * @param null|int $to : Unix timestamp to count checks up to + * @param null|string $checkIds : comma separated list of check IDs + * @param null|string $contactIds : comma separated list of contact IDs + * @param null|string $status : comma separated list of statuses + * @param null|string $via : comma separated list of methods alerts were sent to + * @return mixed|string + * @throws \Exception + */ + public function getActions($limit = 100, $offset = 0, $from = null, $to = null, $checkIds = null, $contactIds = null, $status = null, $via = null) + { + if ($offset > 25000) throw new \Exception('Limit set too high'); + + $url = "/actions/?limit=" . $limit . "&offset=" . $offset; + if ($from != null) $url .= "&from=" . $from; + if ($to != null) $url .= "&to=" . $to; + if ($checkIds != null) $url .= "&checkids=" . $checkIds; + if ($contactIds != null) $url .= "&contactids=" . $contactIds; + if ($status != null) $url .= "&status=" . $status; + if ($via != null) $url .= "&via=" . $via; + + return $this->_doRequest($url); + } + + /** + * Returns a list of the latest error analysis results for a specified check + * + * @param int $checkId : The check ID to get analysis for + * @param int $limit : number of results to return (default = 100) + * @param int $offset : offset for listing + * @return mixed|string + */ + public function getError($checkId, $limit = 100, $offset = 0) + { + $url = "/analysis/" . $checkId . "/?limit=" . $limit . "&offset=" . $offset; + return $this->_doRequest($url); + } + + /** + * Returns the raw result for a specified error analysis. This data is primarily intended for internal + * use, but you might be interested in it as well. However, there is no real documentation for this + * data at the moment. In the future, we may add a new API method that provides a more user-friendly format. + * + * @param int $checkId : of the check + * @param int $analysisId : ID of the analysis + * @return mixed|string + */ + public function getRawAnalysis($checkId, $analysisId) + { + $url = "/analysis/" . $checkId . "/" . $analysisId; + return $this->_doRequest($url); + } + + /** + * Gets a list of all checks on the account + * + * @param int $limit : number of results to return (default=500, max = 25000) + * @param int $offset : offset for listing (requires limit to be set) + * @return array : JSON response encoded to array + * @throws \Exception + */ + public function getChecks($limit = 500, $offset = 0) + { + if ($offset > 25000) throw new \Exception('Limit set too high'); + + $url = "/checks/?limit=" . $limit . "&offset=" . $offset; + return $this->_doRequest($url); + } + + public function getProbes($limit = 500, $offset = 0, $onlyactive = "false") + { + if ($offset > 25000) throw new \Exception('Limit set too high'); + $url = "/probes?limit=" . $limit . "&offset=" . $offset . "&onlyactive=" . $onlyactive; + return $this->_doRequest($url); + } + + public function getTraceroute($target, $probeid = 0) + { + $url = "/traceroute" . "?host=" . $target . "&probeid=" . $probeid; + return $this->_doRequest($url); + } + + + /** + * Returns a detailed description of a specified check + * + * @param int $checkId the ID of the check you wish to get more detail on (see getChecks) + * @return array JSON response encoded to array + */ + public function getCheck($checkId) + { + $url = "/checks/" . $checkId; + return $this->_doRequest($url); + + } + + /** + * Internal function to handle adding all types of check, assumes other functions + * have validated the data + * + * @param Pingdom $check Check object to insert + * @return string JSON string of result + */ + public function addCheck($check) + { + $url = "/checks"; + $postData = $check->_prepData(); + return $this->_doRequest($url, $postData, self::METHOD_POST); + } +} \ No newline at end of file diff --git a/src/Pingdom/Autoload.php b/src/Pingdom/Autoload.php deleted file mode 100644 index 9612dfb..0000000 --- a/src/Pingdom/Autoload.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @link http://github.com/dixcart/php-pingdom - * @link http://dixcart.com/it - * @version 1 - * @license bsd - */ - -/** - * A fallback Autoload class for loading all the Pingdom API classes. - * - * @author Justin Rainbow - */ -class Pingdom_Autoload -{ - /** - * Registers this instance as an autoloader. - * - * @param Boolean $prepend Whether to prepend the autoloader or not - */ - static public function register($prepend = false) - { - spl_autoload_register('Pingdom_Autoload::loadClass', true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - static public function unregister() - { - spl_autoload_unregister('Pingdom_Autoload::loadClass'); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return Boolean|null True, if loaded - */ - static public function loadClass($class) - { - if (0 === strpos($class, 'Pingdom_')) { - $file = dirname(__FILE__) . '/' . str_replace('_', DIRECTORY_SEPARATOR, substr($class, 8)) . '.php'; - - require $file; - return true; - } - } -} \ No newline at end of file diff --git a/src/Pingdom/DNS/Check.php b/src/Pingdom/Dns/Check.php similarity index 93% rename from src/Pingdom/DNS/Check.php rename to src/Pingdom/Dns/Check.php index 0576945..027d5aa 100644 --- a/src/Pingdom/DNS/Check.php +++ b/src/Pingdom/Dns/Check.php @@ -1,5 +1,4 @@ nameServer = $nameServer; $this->expectedIp = $expectedIp; diff --git a/src/Pingdom/HTTP/Check.php b/src/Pingdom/Http/Check.php similarity index 74% rename from src/Pingdom/HTTP/Check.php rename to src/Pingdom/Http/Check.php index 38d9e07..69b8d3d 100644 --- a/src/Pingdom/HTTP/Check.php +++ b/src/Pingdom/Http/Check.php @@ -23,7 +23,11 @@ * @license bsd */ -class Pingdom_HTTP_Check extends Pingdom_Check +namespace Pingdom\Http; + +use Pingdom\Pingdom; + +class Check extends Pingdom { public $url = "/"; public $encryption = false; @@ -34,26 +38,27 @@ class Pingdom_HTTP_Check extends Pingdom_Check public $postData = null; public $requestHeaders = array(); - function __construct($name, $host) { + function __construct($name, $host) + { parent::__construct($name, $host, "http"); } - function _prepData() { + function _prepData() + { $post = parent::_prepData(); - $post += "&url=" . $this->url; - $post += "&encryption=" . $this->encryption; - $post += "&port=" . $this->port; - if ($this->auth != null) $post += "&auth=" . $this->auth; - if ($this->shouldContain != null) $post += "&shouldcontain=" . $this->shouldContain; - if ($this->shouldNotContain != null) $post += "&shouldnotcontain=" . $this->shouldNotContain; + $post .= "&url=" . $this->url; + $post .= "&encryption=" . $this->encryption; + $post .= "&port=" . $this->port; + if ($this->auth != null) $post .= "&auth=" . $this->auth; + if ($this->shouldContain != null) $post .= "&shouldcontain=" . $this->shouldContain; + if ($this->shouldNotContain != null) $post .= "&shouldnotcontain=" . $this->shouldNotContain; //if ($this->postData != null) $post += "&postdata=" . $this->postData; //TODO: Find out how this should actually be formatted, how do you POST POST data? if (!empty($this->requestHeaders)) { $i = 0; - foreach($this->requestHeaders as $header) - { + foreach ($this->requestHeaders as $header) { $i++; - $post =+ "&requestheadername" . $i . "=" . $header; + $post = +"&requestheadername" . $i . "=" . $header; } } return $post; diff --git a/src/Pingdom/HTTP/Custom/Check.php b/src/Pingdom/Http/Custom/Check.php similarity index 90% rename from src/Pingdom/HTTP/Custom/Check.php rename to src/Pingdom/Http/Custom/Check.php index ba20874..7eee7be 100644 --- a/src/Pingdom/HTTP/Custom/Check.php +++ b/src/Pingdom/Http/Custom/Check.php @@ -22,8 +22,11 @@ * @version 1 * @license bsd */ +namespace Pingdom\Http\Custom; -class Pingdom_HTTP_Custom_Check extends Pingdom_Check +use Pingdom\Pingdom; + +class Check extends Pingdom { public $url = "/"; public $encryption = false; @@ -31,7 +34,8 @@ class Pingdom_HTTP_Custom_Check extends Pingdom_Check public $auth = null; public $additionalUrls = array(); - function __construct($name, $host, $url) { + function __construct($name, $host, $url) + { parent::__construct($name, $host, "httpcustom"); $this->url = $url; } diff --git a/src/Pingdom/IMAP/Check.php b/src/Pingdom/Imap/Check.php similarity index 90% rename from src/Pingdom/IMAP/Check.php rename to src/Pingdom/Imap/Check.php index 99d13e2..491d8b8 100644 --- a/src/Pingdom/IMAP/Check.php +++ b/src/Pingdom/Imap/Check.php @@ -22,14 +22,18 @@ * @version 1 * @license bsd */ +namespace Pingdom\Imap; -class Pingdom_IMAP_Check extends Pingdom_Check +use Pingdom\Pingdom; + +class Check extends Pingdom { public $port = 143; public $stringToExpect = null; public $encryption = false; - function __construct($name, $host) { + function __construct($name, $host) + { parent::__construct($name, $host, "imap"); } diff --git a/src/Pingdom/Ping/Check.php b/src/Pingdom/Ping/Check.php index 9cb836b..ac2c1d4 100644 --- a/src/Pingdom/Ping/Check.php +++ b/src/Pingdom/Ping/Check.php @@ -22,10 +22,14 @@ * @version 1 * @license bsd */ +namespace Pingdom\Ping; -class Pingdom_Ping_Check extends Pingdom_Check +use Pingdom\Pingdom; + +class Check extends Pingdom { - function __construct($name, $host) { + function __construct($name, $host) + { parent::__construct($name, $host, "ping"); } } diff --git a/src/Pingdom/Check.php b/src/Pingdom/Pingdom.php similarity index 73% rename from src/Pingdom/Check.php rename to src/Pingdom/Pingdom.php index 9a8d5bb..b7f217e 100644 --- a/src/Pingdom/Check.php +++ b/src/Pingdom/Pingdom.php @@ -1,5 +1,4 @@ name; - $post += "&host=" . $this->host; - $post += "&type=" . $this->type; - $post += "&paused=" . $this->paused; - $post += "&resolution=" . $this->resolution; - if ($this->contactIds != null) - { - $post += "&contactids=" . $this->contactIds; - $post += "&sendtoemail=" . $this->sendToEmail; - $post += "&sendtosms=" . $this->sendToSms; - $post += "&sendtotwitter=" . $this->sendToSms; - $post += "&sendtoiphone=" . $this->sendToIphone; - $post += "&sendnotificationwhendown=" . $this->notifyWhenDown; - $post += "¬ifyagainevery=" . $this->notifyAgainEvery; - $post += "¬ifywhenbackup=" . $this->notifyWhenBack; + $post .= "name=" . $this->name; + $post .= "&host=" . $this->host; + $post .= "&type=" . $this->type; + $post .= "&paused=" . $this->paused; + $post .= "&resolution=" . $this->resolution; + if ($this->contactIds != null) { + $post .= "&contactids=" . $this->contactIds; + $post .= "&sendtoemail=" . $this->sendToEmail; + $post .= "&sendtosms=" . $this->sendToSms; + $post .= "&sendtotwitter=" . $this->sendToSms; + $post .= "&sendtoiphone=" . $this->sendToIphone; + $post .= "&sendnotificationwhendown=" . $this->notifyWhenDown; + $post .= "¬ifyagainevery=" . $this->notifyAgainEvery; + $post .= "¬ifywhenbackup=" . $this->notifyWhenBack; } return $post; diff --git a/src/Pingdom/POP3/Check.php b/src/Pingdom/Pop3/Check.php similarity index 90% rename from src/Pingdom/POP3/Check.php rename to src/Pingdom/Pop3/Check.php index 607c6fb..2f87570 100644 --- a/src/Pingdom/POP3/Check.php +++ b/src/Pingdom/Pop3/Check.php @@ -22,14 +22,18 @@ * @version 1 * @license bsd */ +namespace Pingdom\Pop3; -class Pingdom_POP3_Check extends Pingdom_Check +use Pingdom\Pingdom; + +class Check extends Pingdom { public $port = 110; public $stringToExpect = null; public $encryption = false; - function __construct($name, $host) { + function __construct($name, $host) + { parent::__construct($name, $host, "pop3"); } diff --git a/src/Pingdom/SMTP/Check.php b/src/Pingdom/Smtp/Check.php similarity index 90% rename from src/Pingdom/SMTP/Check.php rename to src/Pingdom/Smtp/Check.php index b5a538f..915db1f 100644 --- a/src/Pingdom/SMTP/Check.php +++ b/src/Pingdom/Smtp/Check.php @@ -22,15 +22,19 @@ * @version 1 * @license bsd */ +namespace Pingdom\Smtp; -class Pingdom_SMTP_Check extends Pingdom_Check +use Pingdom\Pingdom; + +class Check extends Pingdom { public $port = 25; public $auth = null; public $stringToExpect = null; public $encryption = false; - function __construct($name, $host) { + function __construct($name, $host) + { parent::__construct($name, $host, "smtp"); } diff --git a/src/Pingdom/TCP/Check.php b/src/Pingdom/Tcp/Check.php similarity index 90% rename from src/Pingdom/TCP/Check.php rename to src/Pingdom/Tcp/Check.php index 40eee16..9bf9bc3 100644 --- a/src/Pingdom/TCP/Check.php +++ b/src/Pingdom/Tcp/Check.php @@ -22,14 +22,18 @@ * @version 1 * @license bsd */ +namespace Pingdom\Tcp; -class Pingdom_TCP_Check extends Pingdom_Check +use Pingdom\Pingdom; + +class Check extends Pingdom { public $port; public $stringToSend = null; public $stringToExpect = null; - function __construct($name, $host, $port) { + function __construct($name, $host, $port) + { parent::__construct($name, $host, "tcp"); $this->port = $port; } diff --git a/src/Pingdom/UDP/Check.php b/src/Pingdom/Udp/Check.php similarity index 93% rename from src/Pingdom/UDP/Check.php rename to src/Pingdom/Udp/Check.php index c9bd9ae..41a16a6 100644 --- a/src/Pingdom/UDP/Check.php +++ b/src/Pingdom/Udp/Check.php @@ -22,14 +22,18 @@ * @version 1 * @license bsd */ +namespace Pingdom\Udp; -class Pingdom_UDP_Check extends Pingdom_Check +use Pingdom\Pingdom; + +class Check extends Pingdom { public $port; public $stringToSend; public $stringToExpect; - function __construct($name, $host, $port, $stringToSend, $stringToExpect) { + function __construct($name, $host, $port, $stringToSend, $stringToExpect) + { parent::__construct($name, $host, "udp"); $this->port = $port; $this->stringToSend = $stringToSend;