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
6
6
7
7
## [ Unreleased]
8
8
9
+ ## [ 1.1.1] - 2020-07-12
10
+ ### Fixed
11
+ - Make JsonMapperInterface availalbe in ServiceProvider
12
+
9
13
## [ 1.1.0] - 2020-07-12
10
14
### Fixed
11
15
- 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 7
7
use Illuminate \Support \ServiceProvider as BaseServiceProvider ;
8
8
use JsonMapper \JsonMapper ;
9
9
use JsonMapper \JsonMapperFactory ;
10
+ use JsonMapper \JsonMapperInterface ;
10
11
11
12
class ServiceProvider extends BaseServiceProvider
12
13
{
@@ -19,19 +20,18 @@ public function register()
19
20
{
20
21
$ this ->mergeConfigFrom (self ::CONFIG_FILE , 'json-mapper ' );
21
22
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 ' :
25
27
return (new JsonMapperFactory ())->bestFit ();
26
- });
27
- break ;
28
- case 'default ' :
29
- default :
30
- $ this ->app ->singleton (JsonMapper::class, function () {
28
+ case 'default ' :
29
+ default :
31
30
return (new JsonMapperFactory ())->default ();
32
- });
33
- break ;
34
- }
31
+ }
32
+ });
33
+
34
+ $ this ->app ->alias (JsonMapperInterface::class, JsonMapper::class);
35
35
}
36
36
37
37
/**
Original file line number Diff line number Diff line change 6
6
7
7
use Illuminate \Config \Repository ;
8
8
use JsonMapper \JsonMapper ;
9
+ use JsonMapper \JsonMapperInterface ;
9
10
use JsonMapper \LaravelPackage \ServiceProvider ;
10
11
use PHPUnit \Framework \TestCase ;
11
12
@@ -38,6 +39,9 @@ public function testRegisterMakesJsonMapperAvailableInApp(): void
38
39
39
40
$ serviceProvider ->register ();
40
41
42
+ self ::assertTrue ($ app ->has (JsonMapperInterface::class));
43
+ self ::assertInstanceOf (JsonMapperInterface::class, $ app ->make (JsonMapperInterface::class));
44
+
41
45
self ::assertTrue ($ app ->has (JsonMapper::class));
42
46
self ::assertInstanceOf (JsonMapper::class, $ app ->make (JsonMapper::class));
43
47
}
You can’t perform that action at this time.
0 commit comments