19
19
20
20
final class ConfigAbstractFactory implements AbstractFactoryInterface
21
21
{
22
-
23
22
/**
24
23
* Factory can create the service if there is a key for it in the config
25
24
*
26
25
* {@inheritdoc}
27
26
*/
28
27
public function canCreate (\Interop \Container \ContainerInterface $ container , $ requestedName )
29
28
{
30
- if (! $ container ->has ('config ' ) || ! \ array_key_exists (self ::class, $ container ->get ('config ' ))) {
29
+ if (! $ container ->has ('config ' ) || ! array_key_exists (self ::class, $ container ->get ('config ' ))) {
31
30
return false ;
32
31
}
33
32
$ config = $ container ->get ('config ' );
34
33
$ dependencies = $ config [self ::class];
35
34
36
- return \ is_array ($ dependencies ) && \ array_key_exists ($ requestedName , $ dependencies );
35
+ return is_array ($ dependencies ) && array_key_exists ($ requestedName , $ dependencies );
37
36
}
38
37
39
38
/**
@@ -47,31 +46,31 @@ public function __invoke(\Interop\Container\ContainerInterface $container, $requ
47
46
48
47
$ config = $ container ->get ('config ' );
49
48
50
- if (! (\ is_array ($ config ) || $ config instanceof ArrayObject)) {
49
+ if (! (is_array ($ config ) || $ config instanceof ArrayObject)) {
51
50
throw new ServiceNotCreatedException ('Config must be an array or an instance of ArrayObject ' );
52
51
}
53
52
54
- if (! \ array_key_exists (self ::class, $ config )) {
53
+ if (! array_key_exists (self ::class, $ config )) {
55
54
throw new ServiceNotCreatedException ('Cannot find a ` ' . self ::class . '` key in the config array ' );
56
55
}
57
56
58
57
$ dependencies = $ config [self ::class];
59
58
60
- if (! \ is_array ($ dependencies )
61
- || ! \ array_key_exists ($ requestedName , $ dependencies )
62
- || ! \ is_array ($ dependencies [$ requestedName ])
59
+ if (! is_array ($ dependencies )
60
+ || ! array_key_exists ($ requestedName , $ dependencies )
61
+ || ! is_array ($ dependencies [$ requestedName ])
63
62
) {
64
63
throw new ServiceNotCreatedException ('Dependencies config must exist and be an array ' );
65
64
}
66
65
67
66
$ serviceDependencies = $ dependencies [$ requestedName ];
68
67
69
- if ($ serviceDependencies !== \ array_values (\ array_map ('strval ' , $ serviceDependencies ))) {
70
- $ problem = \ json_encode (\ array_map ('gettype ' , $ serviceDependencies ));
68
+ if ($ serviceDependencies !== array_values (array_map ('\ strval ' , $ serviceDependencies ))) {
69
+ $ problem = json_encode (array_map ('\ gettype ' , $ serviceDependencies ));
71
70
throw new ServiceNotCreatedException ('Service message must be an array of strings, ' . $ problem . ' given ' );
72
71
}
73
72
74
- $ arguments = \ array_map ([$ container , 'get ' ], $ serviceDependencies );
73
+ $ arguments = array_map ([$ container , 'get ' ], $ serviceDependencies );
75
74
76
75
return new $ requestedName (...$ arguments );
77
76
}
0 commit comments