File tree Expand file tree Collapse file tree 4 files changed +20
-12
lines changed Expand file tree Collapse file tree 4 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66
77## [ Unreleased]
88
9+ ## [ 1.1.1] - 2020-07-12
10+ ### Fixed
11+ - Make JsonMapperInterface availalbe in ServiceProvider
12+
913## [ 1.1.0] - 2020-07-12
1014### Fixed
1115- Optimised composer dependencies. [ PR #2 ] ( https://github.com/JsonMapper/LaravelPackage/pull/2 )
Original file line number Diff line number Diff line change 1- 1.1.0
1+ 1.1.1
Original file line number Diff line number Diff line change 77use Illuminate \Support \ServiceProvider as BaseServiceProvider ;
88use JsonMapper \JsonMapper ;
99use JsonMapper \JsonMapperFactory ;
10+ use JsonMapper \JsonMapperInterface ;
1011
1112class ServiceProvider extends BaseServiceProvider
1213{
@@ -19,19 +20,18 @@ public function register()
1920 {
2021 $ this ->mergeConfigFrom (self ::CONFIG_FILE , 'json-mapper ' );
2122
22- switch (config ('json-mapper.type ' )) {
23- case 'best-fit ' :
24- $ this ->app ->singleton (JsonMapper::class, function () {
23+ $ config = config ('json-mapper.type ' );
24+ $ this ->app ->singleton (JsonMapperInterface::class, static function () use ($ config ) {
25+ switch ($ config ) {
26+ case 'best-fit ' :
2527 return (new JsonMapperFactory ())->bestFit ();
26- });
27- break ;
28- case 'default ' :
29- default :
30- $ this ->app ->singleton (JsonMapper::class, function () {
28+ case 'default ' :
29+ default :
3130 return (new JsonMapperFactory ())->default ();
32- });
33- break ;
34- }
31+ }
32+ });
33+
34+ $ this ->app ->alias (JsonMapperInterface::class, JsonMapper::class);
3535 }
3636
3737 /**
Original file line number Diff line number Diff line change 66
77use Illuminate \Config \Repository ;
88use JsonMapper \JsonMapper ;
9+ use JsonMapper \JsonMapperInterface ;
910use JsonMapper \LaravelPackage \ServiceProvider ;
1011use PHPUnit \Framework \TestCase ;
1112
@@ -38,6 +39,9 @@ public function testRegisterMakesJsonMapperAvailableInApp(): void
3839
3940 $ serviceProvider ->register ();
4041
42+ self ::assertTrue ($ app ->has (JsonMapperInterface::class));
43+ self ::assertInstanceOf (JsonMapperInterface::class, $ app ->make (JsonMapperInterface::class));
44+
4145 self ::assertTrue ($ app ->has (JsonMapper::class));
4246 self ::assertInstanceOf (JsonMapper::class, $ app ->make (JsonMapper::class));
4347 }
You can’t perform that action at this time.
0 commit comments