Skip to content

Commit

Permalink
changing class name according to psr-0
Browse files Browse the repository at this point in the history
  • Loading branch information
dizda committed Jan 13, 2013
1 parent effe1c5 commit fe4bb42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/CloudApp/API.php
Expand Up @@ -19,7 +19,7 @@
*/

namespace CloudApp;
use CloudApp\Cloud_Exception;
use CloudApp\Exception;

// Type definitions
define('CLOUD_API_TYPE_ALL', null);
Expand All @@ -36,7 +36,7 @@
*
* @author Matthias Plappert
*/
class Cloud_API
class API
{
/**
* The email address of an user. Used for authentication.
Expand Down Expand Up @@ -176,25 +176,25 @@ public function addBookmark($url, $name = '', $private = null) {
public function addFile($path) {
// Check if file exists
if (!file_exists($path)) {
throw new Cloud_Exception('File at path \'' . $path . '\' not found', CLOUD_EXCEPTION_FILE_NOT_FOUND);
throw new Exception('File at path \'' . $path . '\' not found', CLOUD_EXCEPTION_FILE_NOT_FOUND);
}

// Check if path points to a file
if (!is_file($path)) {
throw new Cloud_Exception('Path \'' . $path . '\' doesn\'t point to a file', CLOUD_EXCEPTION_FILE_INVALID);
throw new Exception('Path \'' . $path . '\' doesn\'t point to a file', CLOUD_EXCEPTION_FILE_INVALID);
}

// Check if file is readable
if (!is_readable($path)) {
throw new Cloud_Exception('File at path \'' . $path . '\' isn\'t readable', CLOUD_EXCEPTION_FILE_NOT_READABLE);
throw new Exception('File at path \'' . $path . '\' isn\'t readable', CLOUD_EXCEPTION_FILE_NOT_READABLE);
}

// Request S3 data
$s3 = $this->_execute('http://my.cl.ly/items/new');

// Check if we can upload
if(isset($s3->num_remaining) && $s3->num_remaining < 1) {
throw new Cloud_Exception('Insufficient uploads remaining. Please consider upgrading to CloudApp Pro', CLOUD_EXCEPTION_PRO);
throw new Exception('Insufficient uploads remaining. Please consider upgrading to CloudApp Pro', CLOUD_EXCEPTION_PRO);
}

// Create body and upload file
Expand Down Expand Up @@ -312,7 +312,7 @@ private function _execute($api_url, $body = null, $expected_code = 200, $method
// Check for status code and close connection
$status_code = curl_getinfo($this->_ch, CURLINFO_HTTP_CODE);
if ($status_code != $expected_code) {
throw new Cloud_Exception('Invalid response. Expected HTTP status code \'' . $expected_code . '\' but received \'' . $status_code . '\'', CLOUD_EXCEPTION_INVALID_RESPONSE);
throw new Exception('Invalid response. Expected HTTP status code \'' . $expected_code . '\' but received \'' . $status_code . '\'', CLOUD_EXCEPTION_INVALID_RESPONSE);
}

// Decode JSON and return result
Expand Down Expand Up @@ -343,7 +343,7 @@ private function _upload($url, $body, $expected_code = 303) {
// Check for status code and close connection
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status_code != $expected_code) {
throw new Cloud_Exception('Invalid response. Expected HTTP status code \'' . $expected_code . '\' but received \'' . $status_code . '\'', CLOUD_EXCEPTION_INVALID_RESPONSE);
throw new Exception('Invalid response. Expected HTTP status code \'' . $expected_code . '\' but received \'' . $status_code . '\'', CLOUD_EXCEPTION_INVALID_RESPONSE);
}

// Close
Expand All @@ -355,7 +355,7 @@ private function _upload($url, $body, $expected_code = 303) {
return trim(urldecode($matches[1]));
} else {
// Throw exception
throw new Cloud_Exception('Invalid response. Location header is missing.', CLOUD_EXCEPTION_INVALID_RESPONSE);
throw new Exception('Invalid response. Location header is missing.', CLOUD_EXCEPTION_INVALID_RESPONSE);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/CloudApp/Exception.php
Expand Up @@ -31,6 +31,6 @@
*
* @author Matthias Plappert
*/
class Cloud_Exception extends \Exception { }
class Exception extends \Exception { }

?>

0 comments on commit fe4bb42

Please sign in to comment.