Passed
Push — master ( c1bd78...130d27 )
by Jesús
01:50
created
Commands/MakeRepositoryCommand.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
     public function handle()
29 29
     {
30 30
         $model = $this->argument('model');
31
-        $implementation = strtolower( $this->option('implementation') );
31
+        $implementation = strtolower($this->option('implementation'));
32 32
         
33
-        if ( class_exists( $model ) )
33
+        if (class_exists($model))
34 34
         {
35
-            $supportedImplementations = array_keys( config( 'repositories.supported_implementations' ) );
35
+            $supportedImplementations = array_keys(config('repositories.supported_implementations'));
36 36
             
37
-            if ( $implementation )
37
+            if ($implementation)
38 38
             {
39
-                if ( !in_array( $implementation, $supportedImplementations ) )
39
+                if (!in_array($implementation, $supportedImplementations))
40 40
                 {
41 41
                     $this->error("The implementation '$implementation' is not supported at this moment. Want me to provide support? Open an issue :).");
42 42
                     
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             }
49 49
             
50 50
             // Populate the properties with the right values.
51
-            $this->populateValuesForProperties( $model, $implementation );
51
+            $this->populateValuesForProperties($model, $implementation);
52 52
             
53 53
             $this->createInterface();
54 54
             $this->createRepository();
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             
62 62
         }
63 63
         
64
-        $this->error( "The '$model' model does not exist. Please check that the namespace and the class name are valid.");
64
+        $this->error("The '$model' model does not exist. Please check that the namespace and the class name are valid.");
65 65
         
66 66
     }
67 67
     
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
      * @param $model
70 70
      * @param $implementation
71 71
      */
72
-    protected function populateValuesForProperties( $model, $implementation )
72
+    protected function populateValuesForProperties($model, $implementation)
73 73
     {
74
-        $modelClass = new \ReflectionClass( $model );
74
+        $modelClass = new \ReflectionClass($model);
75 75
         
76 76
         $this->implementation = $implementation;
77 77
         
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
         $this->repositoryClassName = $this->modelClassShortName.'Repository';
82 82
         $this->repositoryInterfaceName = $this->repositoryClassName.'Interface';
83 83
         
84
-        $this->repositoryInterfaceNamespace = rtrim( config( 'repositories.repository_interfaces_namespace' ), '\\' );
85
-        $this->repositoryClassNamespace = $this->repositoryInterfaceNamespace.'\\'.ucfirst( $implementation );
84
+        $this->repositoryInterfaceNamespace = rtrim(config('repositories.repository_interfaces_namespace'), '\\');
85
+        $this->repositoryClassNamespace = $this->repositoryInterfaceNamespace.'\\'.ucfirst($implementation);
86 86
     }
87 87
     
88 88
     /**
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
      */
91 91
     protected function createRepository()
92 92
     {
93
-        $basePath = config( 'repositories.repositories_path' ).'/'.ucfirst( $this->implementation );
93
+        $basePath = config('repositories.repositories_path').'/'.ucfirst($this->implementation);
94 94
         
95 95
         $classFilePath = $basePath.'/'.$this->repositoryClassName.'.php';
96 96
         
97
-        $this->makeDirectory( $basePath );
97
+        $this->makeDirectory($basePath);
98 98
         
99
-        if ( !$this->filesystem->exists( $classFilePath ) )
99
+        if (!$this->filesystem->exists($classFilePath))
100 100
         {
101 101
             // Read the stub and replace
102
-            $this->filesystem->put( $classFilePath, $this->compileRepositoryStub() );
103
-            $this->info("'".ucfirst( $this->implementation )."' implementation created successfully for '$this->modelClassShortName'.");
102
+            $this->filesystem->put($classFilePath, $this->compileRepositoryStub());
103
+            $this->info("'".ucfirst($this->implementation)."' implementation created successfully for '$this->modelClassShortName'.");
104 104
             $this->composer->dumpAutoloads();
105 105
         } else
106 106
         {
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
      */
115 115
     protected function createInterface()
116 116
     {
117
-        $repositoriesBasePath = config( 'repositories.repositories_path' );
117
+        $repositoriesBasePath = config('repositories.repositories_path');
118 118
         
119 119
         $interfaceFilePath = $repositoriesBasePath.'/'.$this->repositoryInterfaceName.'.php';
120 120
         
121
-        $this->makeDirectory( $repositoriesBasePath );
121
+        $this->makeDirectory($repositoriesBasePath);
122 122
         
123
-        if ( !$this->filesystem->exists( $interfaceFilePath ) )
123
+        if (!$this->filesystem->exists($interfaceFilePath))
124 124
         {
125 125
             // Read the stub and replace
126
-            $this->filesystem->put( $interfaceFilePath, $this->compileRepositoryInterfaceStub() );
126
+            $this->filesystem->put($interfaceFilePath, $this->compileRepositoryInterfaceStub());
127 127
             $this->info("Interface created successfully for '$this->modelClassShortName'.");
128 128
             $this->composer->dumpAutoloads();
129 129
         } else
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
      */
139 139
     protected function compileRepositoryInterfaceStub()
140 140
     {
141
-        $stub = $this->filesystem->get(__DIR__ . '/../stubs/repository-interface.stub');
141
+        $stub = $this->filesystem->get(__DIR__.'/../stubs/repository-interface.stub');
142 142
         
143
-        $stub = $this->replaceInterfaceNamespace( $stub );
144
-        $stub = $this->replaceInterfaceName( $stub );
143
+        $stub = $this->replaceInterfaceNamespace($stub);
144
+        $stub = $this->replaceInterfaceName($stub);
145 145
         
146 146
         return $stub;
147 147
     }
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
      */
152 152
     protected function compileRepositoryStub()
153 153
     {
154
-        $stub = $this->filesystem->get(__DIR__ . '/../stubs/repository.stub');
154
+        $stub = $this->filesystem->get(__DIR__.'/../stubs/repository.stub');
155 155
         
156
-        $stub = $this->replaceInterfaceNamespace( $stub );
157
-        $stub = $this->replaceInterfaceName( $stub );
158
-        $stub = $this->replaceParentRepositoryClassNamespaceAndName( $stub );
159
-        $stub = $this->replaceRepositoryClassNamespaceAndName( $stub );
160
-        $stub = $this->replaceModelClassNamespaceAndName( $stub );
156
+        $stub = $this->replaceInterfaceNamespace($stub);
157
+        $stub = $this->replaceInterfaceName($stub);
158
+        $stub = $this->replaceParentRepositoryClassNamespaceAndName($stub);
159
+        $stub = $this->replaceRepositoryClassNamespaceAndName($stub);
160
+        $stub = $this->replaceModelClassNamespaceAndName($stub);
161 161
         
162 162
         return $stub;
163 163
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      * @param $stub
167 167
      * @return $this
168 168
      */
169
-    private function replaceInterfaceNamespace( $stub )
169
+    private function replaceInterfaceNamespace($stub)
170 170
     {
171 171
         return str_replace('{{repositoryInterfaceNamespace}}', $this->repositoryInterfaceNamespace, $stub);
172 172
     }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      * @param $stub
176 176
      * @return mixed
177 177
      */
178
-    private function replaceInterfaceName( $stub )
178
+    private function replaceInterfaceName($stub)
179 179
     {
180 180
         return str_replace('{{repositoryInterfaceName}}', $this->repositoryInterfaceName, $stub);
181 181
     }
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
      * @param $stub
186 186
      * @return mixed
187 187
      */
188
-    private function replaceParentRepositoryClassNamespaceAndName( $stub )
188
+    private function replaceParentRepositoryClassNamespaceAndName($stub)
189 189
     {
190
-        $implementations = config( 'repositories.supported_implementations' );
190
+        $implementations = config('repositories.supported_implementations');
191 191
         
192
-        $parentClassImplementation = $implementations[ $this->implementation ];
192
+        $parentClassImplementation = $implementations[$this->implementation];
193 193
         
194 194
         $reflex = new \ReflectionClass($parentClassImplementation);
195 195
         
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      * @param $stub
203 203
      * @return mixed
204 204
      */
205
-    private function replaceRepositoryClassNamespaceAndName( $stub )
205
+    private function replaceRepositoryClassNamespaceAndName($stub)
206 206
     {
207 207
         $stub = str_replace('{{repositoryClassName}}', $this->repositoryClassName, $stub);
208 208
         
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      * @param $stub
215 215
      * @return mixed
216 216
      */
217
-    private function replaceModelClassNamespaceAndName( $stub )
217
+    private function replaceModelClassNamespaceAndName($stub)
218 218
     {
219 219
         $stub = str_replace('{{modelName}}', $this->modelClassShortName, $stub);
220 220
         
Please login to merge, or discard this patch.
Commands/MakeCriteriaCommand.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
     public function handle()
29 29
     {
30 30
         $criteria = $this->argument('criteria');
31
-        $implementation = strtolower( $this->option('implementation') );
31
+        $implementation = strtolower($this->option('implementation'));
32 32
 
33
-        $this->populateValuesForProperties( $criteria, $implementation );
33
+        $this->populateValuesForProperties($criteria, $implementation);
34 34
         $this->createCriteria();
35 35
 
36 36
         $this->info('Generating autoload...');
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
      * @param $criteria
44 44
      * @param $implementation
45 45
      */
46
-    protected function populateValuesForProperties( $criteria, $implementation )
46
+    protected function populateValuesForProperties($criteria, $implementation)
47 47
     {
48 48
         $this->implementation = $implementation ? $implementation : $this->findDefaultImplementation();
49 49
 
50
-        $criteriaNameForFolder = str_replace('\\', '/', $criteria );
51
-        $this->criteriaFolder = ucfirst( $this->implementation );
50
+        $criteriaNameForFolder = str_replace('\\', '/', $criteria);
51
+        $this->criteriaFolder = ucfirst($this->implementation);
52 52
 
53
-        $folder = pathinfo( $criteriaNameForFolder , PATHINFO_DIRNAME );;
54
-        if ( $folder ) $this->criteriaFolder .= '/'.$folder;
53
+        $folder = pathinfo($criteriaNameForFolder, PATHINFO_DIRNAME); ;
54
+        if ($folder) $this->criteriaFolder .= '/'.$folder;
55 55
 
56
-        $this->criteriaClassName = pathinfo( $criteriaNameForFolder , PATHINFO_FILENAME );
57
-        $this->criteriaClassNamespace = rtrim( config( 'repositories.criterias_namespace' ), '\\' ) . '\\' . str_replace( '/', '\\', $this->criteriaFolder );
56
+        $this->criteriaClassName = pathinfo($criteriaNameForFolder, PATHINFO_FILENAME);
57
+        $this->criteriaClassNamespace = rtrim(config('repositories.criterias_namespace'), '\\').'\\'.str_replace('/', '\\', $this->criteriaFolder);
58 58
     }
59 59
 
60 60
     /**
@@ -62,18 +62,18 @@  discard block
 block discarded – undo
62 62
      */
63 63
     protected function createCriteria()
64 64
     {
65
-        $basePath = config( 'repositories.criterias_path' );
65
+        $basePath = config('repositories.criterias_path');
66 66
 
67
-        if ( $this->criteriaFolder ) $basePath .= '/'.$this->criteriaFolder;
67
+        if ($this->criteriaFolder) $basePath .= '/'.$this->criteriaFolder;
68 68
 
69
-        $this->makeDirectory( $basePath );
69
+        $this->makeDirectory($basePath);
70 70
 
71
-        $criteriaFilePath = $basePath .'/'.$this->criteriaClassName.'.php';
71
+        $criteriaFilePath = $basePath.'/'.$this->criteriaClassName.'.php';
72 72
 
73
-        if ( !$this->filesystem->exists( $criteriaFilePath ) )
73
+        if (!$this->filesystem->exists($criteriaFilePath))
74 74
         {
75 75
             // Read the stub and replace
76
-            $this->filesystem->put( $criteriaFilePath, $this->compileCriteriaStub() );
76
+            $this->filesystem->put($criteriaFilePath, $this->compileCriteriaStub());
77 77
             $this->info("Criteria '$this->criteriaClassName' created successfully in '$criteriaFilePath'.");
78 78
             $this->composer->dumpAutoloads();
79 79
         } else
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
      */
89 89
     protected function compileCriteriaStub( )
90 90
     {
91
-        $stub = $this->filesystem->get(__DIR__ . '/../stubs/eloquent-criteria.stub');
91
+        $stub = $this->filesystem->get(__DIR__.'/../stubs/eloquent-criteria.stub');
92 92
 
93
-        $stub = $this->replaceCriteriaNamespace( $stub );
94
-        $stub = $this->replaceCriteriaName( $stub );
93
+        $stub = $this->replaceCriteriaNamespace($stub);
94
+        $stub = $this->replaceCriteriaName($stub);
95 95
 
96 96
         return $stub;
97 97
     }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @param $stub
102 102
      * @return mixed
103 103
      */
104
-    private function replaceCriteriaNamespace( $stub )
104
+    private function replaceCriteriaNamespace($stub)
105 105
     {
106 106
         return str_replace('{{criteriaNamespace}}', $this->criteriaClassNamespace, $stub);
107 107
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      * @param $stub
111 111
      * @return mixed
112 112
      */
113
-    private function replaceCriteriaName( $stub )
113
+    private function replaceCriteriaName($stub)
114 114
     {
115 115
         return str_replace('{{criteriaClassName}}', $this->criteriaClassName, $stub);
116 116
     }
Please login to merge, or discard this patch.