@@ -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,43 +49,43 @@ 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 | - $implementation = $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 | + $implementation = $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 | - $interfaceName = pathinfo( $repo, PATHINFO_FILENAME ); |
|
65 | - if ( in_array( $interfaceName, $skipRepositories ) ) continue; |
|
64 | + $interfaceName = pathinfo($repo, PATHINFO_FILENAME); |
|
65 | + if (in_array($interfaceName, $skipRepositories)) continue; |
|
66 | 66 | else |
67 | 67 | { |
68 | - $commonName = str_replace( 'Interface', '', $interfaceName ); |
|
68 | + $commonName = str_replace('Interface', '', $interfaceName); |
|
69 | 69 | $interfaceFullClassName = $baseNamespace.$interfaceName; |
70 | 70 | |
71 | - foreach( $implementationBindings as $engine => $bindRepositories ) |
|
71 | + foreach ($implementationBindings as $engine => $bindRepositories) |
|
72 | 72 | { |
73 | - if ( $bindRepositories === 'default' ) continue; |
|
74 | - else if ( in_array( $interfaceName, $bindRepositories ) ) |
|
73 | + if ($bindRepositories === 'default') continue; |
|
74 | + else if (in_array($interfaceName, $bindRepositories)) |
|
75 | 75 | { |
76 | 76 | $implementation = $engine; |
77 | 77 | break; |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | - $fullClassName = $baseNamespace.ucfirst( camel_case( $implementation ) ).'\\'.$commonName; |
|
81 | + $fullClassName = $baseNamespace.ucfirst(camel_case($implementation)).'\\'.$commonName; |
|
82 | 82 | |
83 | - if ( class_exists( $fullClassName ) ) |
|
83 | + if (class_exists($fullClassName)) |
|
84 | 84 | { |
85 | 85 | // Bind the class. |
86 | - $this->app->bind( $interfaceFullClassName, function ( $app ) use ( $fullClassName ) |
|
86 | + $this->app->bind($interfaceFullClassName, function($app) use ($fullClassName) |
|
87 | 87 | { |
88 | - return $app->make( $fullClassName ); |
|
88 | + return $app->make($fullClassName); |
|
89 | 89 | }); |
90 | 90 | } |
91 | 91 | } |
@@ -98,14 +98,14 @@ discard block |
||
98 | 98 | * @param $implementations |
99 | 99 | * @return array|mixed|string |
100 | 100 | */ |
101 | - private function findDefaultImplementation( $implementations ) |
|
101 | + private function findDefaultImplementation($implementations) |
|
102 | 102 | { |
103 | - $filtered = array_filter( $implementations, function( $k ) { |
|
103 | + $filtered = array_filter($implementations, function($k) { |
|
104 | 104 | return $k === 'default'; |
105 | 105 | }); |
106 | 106 | |
107 | 107 | $default = array_keys($filtered); |
108 | - $default = is_array( $default ) ? $default[0] : $default; |
|
108 | + $default = is_array($default) ? $default[0] : $default; |
|
109 | 109 | |
110 | 110 | return $default ? $default : 'eloquent'; |
111 | 111 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | private function registerRepositoryGenerator() |
117 | 117 | { |
118 | - $this->app->singleton('command.repository', function ($app) |
|
118 | + $this->app->singleton('command.repository', function($app) |
|
119 | 119 | { |
120 | 120 | return $app['OkayBueno\Repositories\Commands\MakeRepositoryCommand']; |
121 | 121 | }); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | private function registerCriteriaGenerator() |
131 | 131 | { |
132 | - $this->app->singleton('command.criteria', function ($app) |
|
132 | + $this->app->singleton('command.criteria', function($app) |
|
133 | 133 | { |
134 | 134 | return $app['OkayBueno\Repositories\Commands\MakeCriteriaCommand']; |
135 | 135 | }); |
@@ -62,16 +62,18 @@ |
||
62 | 62 | foreach( $allRepos as $repo ) |
63 | 63 | { |
64 | 64 | $interfaceName = pathinfo( $repo, PATHINFO_FILENAME ); |
65 | - if ( in_array( $interfaceName, $skipRepositories ) ) continue; |
|
66 | - else |
|
65 | + if ( in_array( $interfaceName, $skipRepositories ) ) { |
|
66 | + continue; |
|
67 | + } else |
|
67 | 68 | { |
68 | 69 | $commonName = str_replace( 'Interface', '', $interfaceName ); |
69 | 70 | $interfaceFullClassName = $baseNamespace.$interfaceName; |
70 | 71 | |
71 | 72 | foreach( $implementationBindings as $engine => $bindRepositories ) |
72 | 73 | { |
73 | - if ( $bindRepositories === 'default' ) continue; |
|
74 | - else if ( in_array( $interfaceName, $bindRepositories ) ) |
|
74 | + if ( $bindRepositories === 'default' ) { |
|
75 | + continue; |
|
76 | + } else if ( in_array( $interfaceName, $bindRepositories ) ) |
|
75 | 77 | { |
76 | 78 | $implementation = $engine; |
77 | 79 | break; |