Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
50.00% |
1 / 2 |
CRAP | |
78.95% |
15 / 19 |
| OcrProvider | |
0.00% |
0 / 1 |
|
50.00% |
1 / 2 |
4.15 | |
78.95% |
15 / 19 |
| boot | |
100.00% |
1 / 1 |
1 | |
100.00% |
4 / 4 |
|||
| register | |
0.00% |
0 / 1 |
3.17 | |
73.33% |
11 / 15 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Qmp\Laravel\Ocr\Providers; |
| 4 | |
| 5 | use Illuminate\Support\ServiceProvider; |
| 6 | use Qmp\Laravel\Ocr\Ocr\Config; |
| 7 | use Qmp\Laravel\Ocr\Ocr\Providers\ProviderInterface; |
| 8 | use Qmp\Laravel\MicroService\DbConnection\DbConnection; |
| 9 | use Qmp\Laravel\MicroService\QueueConnection\QueueConnection; |
| 10 | |
| 11 | class OcrProvider extends ServiceProvider |
| 12 | { |
| 13 | /** |
| 14 | * Boot the service provider. |
| 15 | * |
| 16 | * @return void |
| 17 | */ |
| 18 | public function boot() |
| 19 | { |
| 20 | $this->loadMigrationsFrom(__DIR__ . '/../database/migrations/'); |
| 21 | $path = realpath(__DIR__ . '/../../config/ocr.php'); |
| 22 | $this->mergeConfigFrom($path, 'ocr'); |
| 23 | } |
| 24 | |
| 25 | public function register() |
| 26 | { |
| 27 | DbConnection::mergeFromFile(realpath(__DIR__ . '/../../config/connection.php')); |
| 28 | QueueConnection::mergeFromFile(realpath(__DIR__ . '/../../config/queue.php')); |
| 29 | |
| 30 | $this->app->singleton(Config::class, function () { |
| 31 | $config = new Config(); |
| 32 | if ($this->app->runningInConsole() && !$this->app->runningUnitTests()) { |
| 33 | $config->getDataFromCommand(); |
| 34 | } else { |
| 35 | $config->getDataFromRequest(); |
| 36 | } |
| 37 | |
| 38 | return $config; |
| 39 | }); |
| 40 | |
| 41 | $this->app->bind(ProviderInterface::class, function () { |
| 42 | $config = resolve(Config::class); |
| 43 | $providerClassnameToUse = $config->getProviderClassname(); |
| 44 | return new $providerClassnameToUse($config); |
| 45 | }); |
| 46 | } |
| 47 | } |