I am making a class in php whose definition is given below.
<?php
// A PHP class to log every exception on bugsnag account.
// All classes that make 3rd party request must extend this class
// importing all the dependencies
require_once realpath('bugsnag.phar');
require_once realpath('guzzle.phar');
require_once realpath('vendor/autoload.php');
class BugSnagLogger {
private $bugsnag;
private $bugSnagAPIKey;
// Initializing the BugSnag Instance in the constructor itself.
public function __construct($bugSnagAPIKey) {
$this->bugSnagAPIKey = $bugSnagAPIKey;
$this->$bugsnag = BugsnagClient::make($this->bugSnagAPIKey);
BugsnagHandler::register($this->$bugsnag);
}
// Method to catchExceptions.
public function catchException(Exception $exception) {
$this->bugsnag->notifyException($exception);
}
}
$logger = new BugSnagLogger('a7ce9f54025c3873c34775e8a7001e6e');
$logger.catchException(new Exception('Custom Exception by Sparsh.'));
?>
On Executing the above code I am getting the error Call to undefined function catchException()
. I don’t know what I am doing wrong in this case, can someone please help me with this ?.