diff --git a/.gitignore b/.gitignore index c55784d..c7d3e02 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -composer.lock -/vendor/ +composer.lock +/vendor/ diff --git a/LICENSE b/LICENSE index cb3012e..d844a54 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2019 Dave Mc Nicoll - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2019 Dave Mc Nicoll + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index fa383e7..ef34667 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# thebugs -A PSR-15 compliant library helping to trace errors in development and production environment. - +# thebugs +A PSR-15 compliant library helping to trace errors in development and production environment. + diff --git a/composer.json b/composer.json index 06889cf..497b178 100644 --- a/composer.json +++ b/composer.json @@ -1,19 +1,19 @@ -{ - "name": "mcnd/thebugs", - "description": "A PSR-15 compliant library helping to trace errors in development and production environment", - "keywords" : ["debug","error","bug"], - "type": "library", - "license": "MIT", - "authors": [ - { - "name": "Dave Mc Nicoll", - "email": "info@mcnd.ca" - } - ], - "require": {}, - "autoload": { - "psr-4": { - "TheBugs\\": "src/" - } - } -} +{ + "name": "mcnd/thebugs", + "description": "A PSR-15 compliant library helping to trace errors in development and production environment", + "keywords" : ["debug","error","bug"], + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Dave Mc Nicoll", + "email": "info@mcnd.ca" + } + ], + "require": {}, + "autoload": { + "psr-4": { + "TheBugs\\": "src/" + } + } +} diff --git a/src/Email/EmailConfiguration.php b/src/Email/EmailConfiguration.php index a13f9f7..9253658 100644 --- a/src/Email/EmailConfiguration.php +++ b/src/Email/EmailConfiguration.php @@ -18,6 +18,12 @@ class EmailConfiguration public $smtpUseTLS = false; + public $toAddress = ""; + + public $fromAddress = ""; + + public $fromName = ""; + public function __construct($type = self::AUTH_TYPE_SMTP) { $this->type = $type; diff --git a/src/EmailErrorMiddleware.php b/src/EmailErrorMiddleware.php index 67364bb..c90a043 100644 --- a/src/EmailErrorMiddleware.php +++ b/src/EmailErrorMiddleware.php @@ -2,19 +2,11 @@ namespace TheBugs; -use Psr\Http\Message\ResponseFactoryInterface, - Psr\Container\ContainerInterface, - Psr\Http\Message\ResponseInterface, +use Psr\Http\Message\ResponseInterface, Psr\Http\Message\ServerRequestInterface, Psr\Http\Server\MiddlewareInterface, Psr\Http\Server\RequestHandlerInterface; -use Zend\Diactoros\Response, - Zend\Diactoros\ServerRequest, - Zend\Diactoros\Stream, - Zend\Diactoros\Uri; - - class EmailErrorMiddleware implements MiddlewareInterface { protected /* EmailConfiguration */ $emailConfiguration; @@ -35,9 +27,8 @@ class EmailErrorMiddleware implements MiddlewareInterface $response = $handler->handle($request); if ( $response->getStatusCode() === 500 ) { - - $this->mailer->setTo('dave.mcnicoll@cslsj.qc.ca'); - $this->mailer->setFrom(['test@johndoe.com' => 'John Doe']); + $this->mailer->setTo($this->emailConfiguration->toAddress); + $this->mailer->setFrom([$this->emailConfiguration->fromAddress => $this->emailConfiguration->fromName]); $bugReport = $response->getBody()->__toString(); diff --git a/src/Exception/JavascriptException.php b/src/Exception/JavascriptException.php index 0a5a3c8..e2a82b3 100644 --- a/src/Exception/JavascriptException.php +++ b/src/Exception/JavascriptException.php @@ -1,26 +1,26 @@ -message = $message; - $this->code = $code; - $this->previous = $previous; - $this->file = $file; - $this->line = $line; - $this->url = $url; - $this->stacktrace = $trace; - } - - public function __toString() { - return __CLASS__ . ": [{$this->url}:{$this->code}]: {$this->message}\n" . json_encode($this->stacktrace); - } - -} +message = $message; + $this->code = $code; + $this->previous = $previous; + $this->file = $file; + $this->line = $line; + $this->url = $url; + $this->stacktrace = $trace; + } + + public function __toString() { + return __CLASS__ . ": [{$this->url}:{$this->code}]: {$this->message}\n" . json_encode($this->stacktrace); + } + +}