Skip to content

Commit

Permalink
Throw proper exception when required package is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Mar 3, 2019
1 parent 108da92 commit 7a3a2e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"require-dev": {
"phpunit/phpunit": "^5.7|^6.0"
},
"suggest": {
"symfony/http-foundation": "Install if you want to use QrCodeResponse"
},
"autoload": {
"psr-4": {
"Endroid\\QrCode\\": "src/"
Expand Down
4 changes: 4 additions & 0 deletions src/Response/QrCodeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
use Endroid\QrCode\QrCodeInterface;
use Symfony\Component\HttpFoundation\Response;

if (class_exists(Response::class)) {
throw new \Exception('QrCodeResponse requires symfony/http-foundation');
}

class QrCodeResponse extends Response
{
public function __construct(QrCodeInterface $qrCode)
Expand Down
4 changes: 2 additions & 2 deletions tests/QrCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function writerNamesProvider()
['debug', null],
['eps', null],
['png', 'data:image/png;base64'],
['svg', 'data:image/svg+xml;base64']
['svg', 'data:image/svg+xml;base64'],
];
}

Expand Down Expand Up @@ -113,7 +113,7 @@ public function extensionsProvider()
['txt', null],
['eps', null],
['png', 'data:image/png;base64'],
['svg', 'data:image/svg+xml;base64']
['svg', 'data:image/svg+xml;base64'],
];
}

Expand Down

0 comments on commit 7a3a2e3

Please sign in to comment.