thecaliskan /
laravel-tdk
| 1 | <?php |
||
| 2 | |||
| 3 | namespace TheCaliskan\TDK; |
||
| 4 | |||
| 5 | use Illuminate\Http\Client\Response; |
||
| 6 | use Illuminate\Support\ServiceProvider; |
||
| 7 | |||
| 8 | class TDKServiceProvider extends ServiceProvider |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Register any application services. |
||
| 12 | * |
||
| 13 | * @return void |
||
| 14 | */ |
||
| 15 | public function register() |
||
| 16 | { |
||
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Bootstrap any application services. |
||
| 21 | * |
||
| 22 | * @return void |
||
| 23 | */ |
||
| 24 | public function boot() |
||
| 25 | { |
||
| 26 | Response::macro('tdkThrow', function () { |
||
| 27 | $this->throw(); |
||
| 28 | |||
| 29 | if (isset($this->json()['error'])) { |
||
| 30 | throw new TDKException($this); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 31 | } |
||
| 32 | |||
| 33 | return $this; |
||
| 34 | }); |
||
| 35 | |||
| 36 | $this->app->singleton('thecaliskan-tdk', function ($app) { |
||
| 37 | return new TDK($app); |
||
| 38 | }); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Get the services provided by the provider. |
||
| 43 | * |
||
| 44 | * @return array |
||
| 45 | */ |
||
| 46 | public function provides() |
||
| 47 | { |
||
| 48 | return [ |
||
| 49 | 'thecaliskan-tdk', |
||
| 50 | ]; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |