@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | // merge default config |
33 | 33 | $this->mergeConfigFrom( |
34 | - __DIR__.$this->configPath , 'repositories' |
|
34 | + __DIR__.$this->configPath, 'repositories' |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | // Bind the repositories. |
@@ -49,44 +49,44 @@ discard block |
||
49 | 49 | private function autoBindRepositories() |
50 | 50 | { |
51 | 51 | // Load config parameters needed. |
52 | - $repositoriesBasePath = config( 'repositories.repositories_path' ); |
|
53 | - $baseNamespace = rtrim( config( 'repositories.repository_interfaces_namespace' ), '\\' ) . '\\'; |
|
54 | - $skipRepositories = config( 'repositories.skip' ); |
|
55 | - $implementationBindings = config( 'repositories.bindings' ); |
|
56 | - $defaultImplementation = $this->findDefaultImplementation( $implementationBindings ); |
|
52 | + $repositoriesBasePath = config('repositories.repositories_path'); |
|
53 | + $baseNamespace = rtrim(config('repositories.repository_interfaces_namespace'), '\\').'\\'; |
|
54 | + $skipRepositories = config('repositories.skip'); |
|
55 | + $implementationBindings = config('repositories.bindings'); |
|
56 | + $defaultImplementation = $this->findDefaultImplementation($implementationBindings); |
|
57 | 57 | |
58 | - if ( \File::exists( $repositoriesBasePath ) ) |
|
58 | + if (\File::exists($repositoriesBasePath)) |
|
59 | 59 | { |
60 | - $allRepos = \File::files( $repositoriesBasePath ); |
|
60 | + $allRepos = \File::files($repositoriesBasePath); |
|
61 | 61 | |
62 | - foreach( $allRepos as $repo ) |
|
62 | + foreach ($allRepos as $repo) |
|
63 | 63 | { |
64 | 64 | $implementation = $defaultImplementation; |
65 | - $interfaceName = pathinfo( $repo, PATHINFO_FILENAME ); |
|
66 | - if ( in_array( $interfaceName, $skipRepositories ) ) continue; |
|
65 | + $interfaceName = pathinfo($repo, PATHINFO_FILENAME); |
|
66 | + if (in_array($interfaceName, $skipRepositories)) continue; |
|
67 | 67 | else |
68 | 68 | { |
69 | - $commonName = str_replace( 'Interface', '', $interfaceName ); |
|
69 | + $commonName = str_replace('Interface', '', $interfaceName); |
|
70 | 70 | $interfaceFullClassName = $baseNamespace.$interfaceName; |
71 | 71 | |
72 | - foreach( $implementationBindings as $engine => $bindRepositories ) |
|
72 | + foreach ($implementationBindings as $engine => $bindRepositories) |
|
73 | 73 | { |
74 | - if ( $bindRepositories === 'default' ) continue; |
|
75 | - else if ( in_array( $interfaceName, $bindRepositories ) ) |
|
74 | + if ($bindRepositories === 'default') continue; |
|
75 | + else if (in_array($interfaceName, $bindRepositories)) |
|
76 | 76 | { |
77 | 77 | $implementation = $engine; |
78 | 78 | break; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - $fullClassName = $baseNamespace.ucfirst( camel_case( $implementation ) ).'\\'.$commonName; |
|
82 | + $fullClassName = $baseNamespace.ucfirst(camel_case($implementation)).'\\'.$commonName; |
|
83 | 83 | |
84 | - if ( class_exists( $fullClassName ) ) |
|
84 | + if (class_exists($fullClassName)) |
|
85 | 85 | { |
86 | 86 | // Bind the class. |
87 | - $this->app->bind( $interfaceFullClassName, function ( $app ) use ( $fullClassName ) |
|
87 | + $this->app->bind($interfaceFullClassName, function($app) use ($fullClassName) |
|
88 | 88 | { |
89 | - return $app->make( $fullClassName ); |
|
89 | + return $app->make($fullClassName); |
|
90 | 90 | }); |
91 | 91 | } |
92 | 92 | } |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | * @param $implementations |
100 | 100 | * @return array|mixed|string |
101 | 101 | */ |
102 | - private function findDefaultImplementation( $implementations ) |
|
102 | + private function findDefaultImplementation($implementations) |
|
103 | 103 | { |
104 | - $filtered = array_filter( $implementations, function( $k ) { |
|
104 | + $filtered = array_filter($implementations, function($k) { |
|
105 | 105 | return $k === 'default'; |
106 | 106 | }); |
107 | 107 | |
108 | 108 | $default = array_keys($filtered); |
109 | - $default = is_array( $default ) ? $default[0] : $default; |
|
109 | + $default = is_array($default) ? $default[0] : $default; |
|
110 | 110 | |
111 | 111 | return $default ? $default : 'eloquent'; |
112 | 112 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | private function registerRepositoryGenerator() |
118 | 118 | { |
119 | - $this->app->singleton('command.repository', function ($app) |
|
119 | + $this->app->singleton('command.repository', function($app) |
|
120 | 120 | { |
121 | 121 | return $app['OkayBueno\Repositories\Commands\MakeRepositoryCommand']; |
122 | 122 | }); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | private function registerCriteriaGenerator() |
132 | 132 | { |
133 | - $this->app->singleton('command.criteria', function ($app) |
|
133 | + $this->app->singleton('command.criteria', function($app) |
|
134 | 134 | { |
135 | 135 | return $app['OkayBueno\Repositories\Commands\MakeCriteriaCommand']; |
136 | 136 | }); |
@@ -63,16 +63,18 @@ |
||
63 | 63 | { |
64 | 64 | $implementation = $defaultImplementation; |
65 | 65 | $interfaceName = pathinfo( $repo, PATHINFO_FILENAME ); |
66 | - if ( in_array( $interfaceName, $skipRepositories ) ) continue; |
|
67 | - else |
|
66 | + if ( in_array( $interfaceName, $skipRepositories ) ) { |
|
67 | + continue; |
|
68 | + } else |
|
68 | 69 | { |
69 | 70 | $commonName = str_replace( 'Interface', '', $interfaceName ); |
70 | 71 | $interfaceFullClassName = $baseNamespace.$interfaceName; |
71 | 72 | |
72 | 73 | foreach( $implementationBindings as $engine => $bindRepositories ) |
73 | 74 | { |
74 | - if ( $bindRepositories === 'default' ) continue; |
|
75 | - else if ( in_array( $interfaceName, $bindRepositories ) ) |
|
75 | + if ( $bindRepositories === 'default' ) { |
|
76 | + continue; |
|
77 | + } else if ( in_array( $interfaceName, $bindRepositories ) ) |
|
76 | 78 | { |
77 | 79 | $implementation = $engine; |
78 | 80 | break; |