-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from jr-cologne/bugsnag
Implement Error Handling with Bugsnag
- Loading branch information
Showing
15 changed files
with
448 additions
and
13 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
@@ -23,8 +23,12 @@ | |
|
||
require_once 'vendor/autoload.php'; | ||
|
||
use CryptoStatus\BugsnagClient; | ||
use CryptoStatus\CryptoStatus; | ||
|
||
// initialize error handling | ||
$bugsnag_client = new BugsnagClient; | ||
|
||
$app = new CryptoStatus; | ||
|
||
// initialize app | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/** | ||
* A simple Twitter bot application which posts hourly status updates for the top 10 cryptocurrencies. | ||
* | ||
* PHP version >= 7.0 | ||
* | ||
* LICENSE: MIT, see LICENSE file for more information | ||
* | ||
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
* | ||
* BugsnagClient.php | ||
* | ||
* The client for handling errors with Bugsnag. | ||
* | ||
*/ | ||
|
||
namespace CryptoStatus; | ||
|
||
class BugsnagClient { | ||
|
||
/** | ||
* Constructor, initialization of Bugsnag's error handler | ||
*/ | ||
public function __construct() { | ||
$bugsnag = Bugsnag\Client::make($this->getApiKey()); | ||
Bugsnag\Handler::register($bugsnag); | ||
} | ||
|
||
/** | ||
* Get API key from environment variables | ||
* | ||
* @return string | ||
* @throws BugsnagClientException if Bugsnag API key could not be retrieved | ||
*/ | ||
protected function getApiKey() : string { | ||
$api_key = getenv(BUGSNAG_API_KEY); | ||
|
||
if (empty($api_key)) { | ||
throw new BugsnagClientException("Could not get Bugsnag API Key", 1); | ||
} | ||
|
||
return $api_key; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* A simple Twitter bot application which posts hourly status updates for the top 10 cryptocurrencies. | ||
* | ||
* PHP version >= 7.0 | ||
* | ||
* LICENSE: MIT, see LICENSE file for more information | ||
* | ||
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
* | ||
* BugsnagClientException.php | ||
* | ||
* The Exception of the Bugsnag client | ||
* | ||
*/ | ||
|
||
namespace CryptoStatus\Exceptions; | ||
|
||
use \Exception; | ||
|
||
class BugsnagClientException extends Exception { | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
@@ -47,7 +47,6 @@ class TwitterClient { | |
* Constructor, initialization and authentication with Twitter API | ||
* | ||
* @param Codebird $twitter_client A Cordbird instance | ||
* @param string $twitter_api_credentials_file The Twitter API credentials file | ||
* @throws TwitterClientException if authentication with Twitter API failed | ||
*/ | ||
public function __construct(Codebird $twitter_client) { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author JR Cologne <[email protected]> | ||
* @copyright 2018 JR Cologne | ||
* @license https://github.com/jr-cologne/CryptoStatus/blob/master/LICENSE MIT | ||
* @version v0.1.3 | ||
* @version v0.2.0 | ||
* @link https://github.com/jr-cologne/CryptoStatus GitHub Repository | ||
* | ||
* ________________________________________________________________________________ | ||
|
@@ -31,3 +31,5 @@ | |
const CRYPTO_API = 'https://api.coinmarketcap.com/v1/'; | ||
const CRYPTO_API_ENDPOINT = 'ticker/'; | ||
const CRYPTO_API_LIMIT = 10; | ||
|
||
const BUGSNAG_API_KEY = 'BUGSNAG_API_KEY'; |
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
Oops, something went wrong.