Passed
Push — master ( 648f6a...7057c8 )
by Jesús
02:02
created
RepositoryInterface.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      * @param array $columns Columns to retrieve with the object.
19 19
      * @return mixed Model|NULL An Eloquent object when there is a result, NULL when there are no matches.
20 20
      */
21
-    public function findOneBy( $value = NULL, $field = 'id', array $columns = ['*'] );
21
+    public function findOneBy($value = NULL, $field = 'id', array $columns = ['*']);
22 22
 
23 23
     /**
24 24
      * Finds ALL items the repository abstract without any kind of filter.
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      * @param array $columns Columns to retrieve with the objects.
27 27
      * @return mixed Collection Laravel Eloquent's Collection that may or may not be empty.
28 28
      */
29
-    public function findAll( array $columns = ['*'] );
29
+    public function findAll(array $columns = ['*']);
30 30
 
31 31
     /**
32 32
      * Finds ALL items by the provided field. If NULL specified for the first 2 parameters, then it will take ONLY the
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * @param array $columns Columns to retrieve with the objects.
38 38
      * @return mixed Collection Laravel Eloquent's Collection that may or may not be empty.
39 39
      */
40
-    public function findAllBy( $value = NULL, $field = NULL, array $columns = ['*'] );
40
+    public function findAllBy($value = NULL, $field = NULL, array $columns = ['*']);
41 41
 
42 42
     /**
43 43
      * Finds ALL the items in the repository where the given field is inside the given values.
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param array $columns Columns to retrieve with the objects.
48 48
      * @return mixed Collection Laravel Eloquent's Collection that may or may not be empty.
49 49
      */
50
-    public function findAllWhereIn( array $value, $field,  array $columns = ['*'] );
50
+    public function findAllWhereIn(array $value, $field, array $columns = ['*']);
51 51
 
52 52
     /**
53 53
      * Allows you to eager-load entity relationships when retrieving entities, either with or without criterias.
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      * @param array|string $relations Relations to eager-load along with the entities.
56 56
      * @return mixed The current repository object instance.
57 57
      */
58
-    public function with( $relations );
58
+    public function with($relations);
59 59
 
60 60
     /**
61 61
      * Adds a criteria to the query.
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * @param CriteriaInterface $criteria Object that declares and implements the criteria used.
64 64
      * @return mixed The current repository object instance.
65 65
      */
66
-    public function addCriteria( CriteriaInterface $criteria );
66
+    public function addCriteria(CriteriaInterface $criteria);
67 67
 
68 68
     /**
69 69
      * Skips the current criteria (all of them). Useful when you don't want to reset the object but just not use the
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      * @param bool|TRUE $status If you want to skip the criteria or not.
73 73
      * @return mixed The current repository object instance.
74 74
      */
75
-    public function skipCriteria( $status = TRUE );
75
+    public function skipCriteria($status = TRUE);
76 76
 
77 77
     /**
78 78
      * Returns a Paginator that based on the criteria or filters given.
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @param array $columns Columns to retrieve with the objects.
82 82
      * @return Paginator object with the results and the paginator.
83 83
      */
84
-    public function paginate( $perPage, array $columns = ['*'] );
84
+    public function paginate($perPage, array $columns = ['*']);
85 85
 
86 86
     /**
87 87
      * Allows you to set the current page with using the paginator. Useful when you want to overwrite the $_GET['page']
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      * @param int $page The page you want to retrieve.
91 91
      * @return mixed The current repository object instance.
92 92
      */
93
-    public function setCurrentPage( $page );
93
+    public function setCurrentPage($page);
94 94
 
95 95
     /**
96 96
      * Creates a new entity of the entity type the repository handles, given certain data.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * @param array $data Data the entity will have.
99 99
      * @return mixed Model|NULL An Eloquent object when the entity was created, NULL in case of error.
100 100
      */
101
-    public function create( array $data );
101
+    public function create(array $data);
102 102
 
103 103
     /**
104 104
      * Updates as many entities as the filter matches with the given $data.
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      * @return mixed Model|NULL|integer An Eloquent object representing the updated entity, a number of entities updated if mass updating,
110 110
      * or NULL in case of error.
111 111
      */
112
-    public function updateBy( array $data, $value = NULL, $field = 'id' );
112
+    public function updateBy(array $data, $value = NULL, $field = 'id');
113 113
 
114 114
     /**
115 115
      * Removes as many entities as the filter matches. If softdelete is applied, then they will be soft-deleted.
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @param string $field Field on the database that you will filter by. Default: id.
121 121
      * @return boolean TRUE It will always return TRUE.
122 122
      */
123
-    public function delete( $value = NULL, $field = 'id' );
123
+    public function delete($value = NULL, $field = 'id');
124 124
 
125 125
     /**
126 126
      * @return int number of records matching the criteria (or total amount of records).
@@ -143,6 +143,6 @@  discard block
 block discarded – undo
143 143
      * @param string $field Field on the database that you will filter by.
144 144
      * @return mixed
145 145
      */
146
-    public function destroy( $value = NULL, $field = 'id' );
146
+    public function destroy($value = NULL, $field = 'id');
147 147
 
148 148
 }
149 149
\ No newline at end of file
Please login to merge, or discard this patch.
Extra/CountableInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      * @param int $amount
19 19
      * @return mixed
20 20
      */
21
-    public function incrementCounter( Model $model, $counter, $amount = 1 );
21
+    public function incrementCounter(Model $model, $counter, $amount = 1);
22 22
 
23 23
 
24 24
     /**
@@ -31,5 +31,5 @@  discard block
 block discarded – undo
31 31
      * @param bool|FALSE $allowNegative
32 32
      * @return mixed
33 33
      */
34
-    public function decrementCounter( Model $model, $counter, $amount = 1, $allowNegative = FALSE );
34
+    public function decrementCounter(Model $model, $counter, $amount = 1, $allowNegative = FALSE);
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
Extra/RestorableInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,5 +16,5 @@
 block discarded – undo
16 16
      * @param string $field Column in the DB used for the filter.
17 17
      * @return void
18 18
      */
19
-    public function restore( $value, $field = 'id' );
19
+    public function restore($value, $field = 'id');
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
Commands/MakeRepositoryCommand.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@  discard block
 block discarded – undo
30 30
     public function fire()
31 31
     {
32 32
         $model = $this->argument('model');
33
-        $implementation = strtolower( $this->option('implementation') );
33
+        $implementation = strtolower($this->option('implementation'));
34 34
 
35
-        if ( class_exists( $model ) )
35
+        if (class_exists($model))
36 36
         {
37
-            $supportedImplementations = array_keys( config( 'repositories.supported_implementations' ) );
37
+            $supportedImplementations = array_keys(config('repositories.supported_implementations'));
38 38
 
39
-            if ( $implementation )
39
+            if ($implementation)
40 40
             {
41
-                if ( !in_array( $implementation, $supportedImplementations ) )
41
+                if (!in_array($implementation, $supportedImplementations))
42 42
                 {
43 43
                     $this->error("The implementation '$implementation' is not supported at this moment. Want me to provide support? Open an issue :).");
44 44
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             }
51 51
 
52 52
             // Populate the properties with the right values.
53
-            $this->populateValuesForProperties( $model, $implementation );
53
+            $this->populateValuesForProperties($model, $implementation);
54 54
 
55 55
             $this->createInterface();
56 56
             $this->createRepository();
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
         } else
63 63
         {
64
-            $this->error( "The '$this->modelClassShortName' ('$this->modelClassNamespace\\$this->modelClassShortName') model does not exist. Please check that the namespace and the class name are valid.");
64
+            $this->error("The '$this->modelClassShortName' ('$this->modelClassNamespace\\$this->modelClassShortName') 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 2 patches
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 fire()
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.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,9 @@  discard block
 block discarded – undo
51 51
         $this->criteriaFolder = ucfirst( $this->implementation );
52 52
 
53 53
         $folder = pathinfo( $criteriaNameForFolder , PATHINFO_DIRNAME );;
54
-        if ( $folder ) $this->criteriaFolder .= '/'.$folder;
54
+        if ( $folder ) {
55
+            $this->criteriaFolder .= '/'.$folder;
56
+        }
55 57
 
56 58
         $this->criteriaClassName = pathinfo( $criteriaNameForFolder , PATHINFO_FILENAME );
57 59
         $this->criteriaClassNamespace = rtrim( config( 'repositories.criterias_namespace' ), '\\' ) . '\\' . str_replace( '/', '\\', $this->criteriaFolder );
@@ -64,7 +66,9 @@  discard block
 block discarded – undo
64 66
     {
65 67
         $basePath = config( 'repositories.criterias_path' );
66 68
 
67
-        if ( $this->criteriaFolder ) $basePath .= '/'.$this->criteriaFolder;
69
+        if ( $this->criteriaFolder ) {
70
+            $basePath .= '/'.$this->criteriaFolder;
71
+        }
68 72
 
69 73
         $this->makeDirectory( $basePath );
70 74
 
Please login to merge, or discard this patch.
Commands/MakeBaseCommand.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
     /**
32 32
      * @param $path
33 33
      */
34
-    protected function makeDirectory( $path )
34
+    protected function makeDirectory($path)
35 35
     {
36
-        if ( !$this->filesystem->isDirectory( $path ) )
36
+        if (!$this->filesystem->isDirectory($path))
37 37
         {
38
-            $this->filesystem->makeDirectory( $path, 0775, true, true);
38
+            $this->filesystem->makeDirectory($path, 0775, true, true);
39 39
         }
40 40
     }
41 41
 
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
      */
46 46
     protected function findDefaultImplementation()
47 47
     {
48
-        $implementationBindings = config( 'repositories.bindings' );
48
+        $implementationBindings = config('repositories.bindings');
49 49
 
50
-        $filtered = array_filter( $implementationBindings, function( $k ) {
50
+        $filtered = array_filter($implementationBindings, function($k) {
51 51
             return $k === 'default';
52 52
         });
53 53
 
54 54
         $default = array_keys($filtered);
55
-        $default = is_array( $default ) ? $default[0] : $default;
55
+        $default = is_array($default) ? $default[0] : $default;
56 56
 
57 57
         return $default ? $default : 'eloquent';
58 58
     }
Please login to merge, or discard this patch.
src/Traits/Countable.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
      * @param int $amount
18 18
      * @return Model
19 19
      */
20
-    public function incrementCounter( Model $model, $counter, $amount = 1 )
20
+    public function incrementCounter(Model $model, $counter, $amount = 1)
21 21
     {
22
-        $amount = $this->getAmount( $amount );
22
+        $amount = $this->getAmount($amount);
23 23
 
24
-        if ( $amount ) $model->increment( $counter, $amount );
25
-        else $model->increment( $counter );
24
+        if ($amount) $model->increment($counter, $amount);
25
+        else $model->increment($counter);
26 26
 
27 27
         return $model;
28 28
     }
@@ -35,22 +35,22 @@  discard block
 block discarded – undo
35 35
      * @param bool|FALSE $allowNegative
36 36
      * @return Model
37 37
      */
38
-    public function decrementCounter( Model $model, $counter, $amount = 1, $allowNegative = FALSE )
38
+    public function decrementCounter(Model $model, $counter, $amount = 1, $allowNegative = FALSE)
39 39
     {
40
-        $amount = $this->getAmount( $amount, 1 );
40
+        $amount = $this->getAmount($amount, 1);
41 41
 
42 42
         $currentValue = $model->{$counter};
43 43
         $final = $model->{$counter} - $amount;
44 44
 
45
-        if ( !$allowNegative )
45
+        if (!$allowNegative)
46 46
         {
47
-            if ( $currentValue && $final < 0 )
47
+            if ($currentValue && $final < 0)
48 48
             {
49 49
                 $model->{$counter} = 0;
50 50
                 $model->save();
51 51
             }
52 52
 
53
-        } else $model->decrement( $counter, $amount );
53
+        } else $model->decrement($counter, $amount);
54 54
 
55 55
         return $model;
56 56
     }
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
      * @param null $default
62 62
      * @return int|null
63 63
      */
64
-    private function getAmount( $amount, $default = NULL )
64
+    private function getAmount($amount, $default = NULL)
65 65
     {
66
-        return is_int( $amount ) && $amount > 1 ? $amount : $default;
66
+        return is_int($amount) && $amount > 1 ? $amount : $default;
67 67
     }
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,8 +21,11 @@  discard block
 block discarded – undo
21 21
     {
22 22
         $amount = $this->getAmount( $amount );
23 23
 
24
-        if ( $amount ) $model->increment( $counter, $amount );
25
-        else $model->increment( $counter );
24
+        if ( $amount ) {
25
+            $model->increment( $counter, $amount );
26
+        } else {
27
+            $model->increment( $counter );
28
+        }
26 29
 
27 30
         return $model;
28 31
     }
@@ -50,7 +53,9 @@  discard block
 block discarded – undo
50 53
                 $model->save();
51 54
             }
52 55
 
53
-        } else $model->decrement( $counter, $amount );
56
+        } else {
57
+            $model->decrement( $counter, $amount );
58
+        }
54 59
 
55 60
         return $model;
56 61
     }
Please login to merge, or discard this patch.
src/Traits/Restorable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
      * @param $value
14 14
      * @param string $field
15 15
      */
16
-    public function restore( $value, $field = 'id' )
16
+    public function restore($value, $field = 'id')
17 17
     {
18
-        $this->model->where( $field, $value )->restore();
18
+        $this->model->where($field, $value)->restore();
19 19
     }
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
src/EloquentRepository.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
     /**
23 23
      * @param Model $model
24 24
      */
25
-    public function __construct( Model $model )
25
+    public function __construct(Model $model)
26 26
     {
27 27
         $this->model = $model;
28 28
 
29 29
         // A clean copy of the model is needed when the scope needs to be reset.
30
-        $reflex = new \ReflectionClass( $model );
30
+        $reflex = new \ReflectionClass($model);
31 31
         $this->modelClassName = $reflex->getName();
32 32
 
33 33
         $this->skipCriteria = FALSE;
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
         $this->eagerLoadRelations();
46 46
         $this->applyCriteria();
47 47
 
48
-        if ( !is_null( $value ) ) $this->model = $this->model->where( $field, $value );
48
+        if (!is_null($value)) $this->model = $this->model->where($field, $value);
49 49
 
50
-        $result = $this->model->first( $columns );
50
+        $result = $this->model->first($columns);
51 51
 
52 52
         $this->resetScope();
53 53
 
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
         $this->eagerLoadRelations();
66 66
         $this->applyCriteria();
67 67
 
68
-        if ( !is_null( $value ) && !is_null( $field ) ) $this->model = $this->model->where( $field, $value );
68
+        if (!is_null($value) && !is_null($field)) $this->model = $this->model->where($field, $value);
69 69
 
70
-        $result = $this->model->get( $columns );
70
+        $result = $this->model->get($columns);
71 71
 
72 72
         $this->resetScope();
73 73
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         $this->eagerLoadRelations();
86 86
         $this->applyCriteria();
87
-        $result = $this->model->whereIn( $field, $value )->get( $columns );
87
+        $result = $this->model->whereIn($field, $value)->get($columns);
88 88
 
89 89
         $this->resetScope();
90 90
 
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
      * @param array $columns
96 96
      * @return \Illuminate\Database\Eloquent\Collection|static[]
97 97
      */
98
-    public function findAll( array $columns = ['*'] )
98
+    public function findAll(array $columns = ['*'])
99 99
     {
100 100
         $this->eagerLoadRelations();
101
-        $result = $this->model->all( $columns );
101
+        $result = $this->model->all($columns);
102 102
 
103 103
         $this->resetScope();
104 104
 
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
      * @param array|string $relations
110 110
      * @return $this
111 111
      */
112
-    public function with( $relations )
112
+    public function with($relations)
113 113
     {
114
-        if ( is_string( $relations ) ) $relations = func_get_args();
114
+        if (is_string($relations)) $relations = func_get_args();
115 115
 
116 116
         $this->with = $relations;
117 117
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @param CriteriaInterface $criteria
124 124
      * @return $this
125 125
      */
126
-    public function addCriteria( CriteriaInterface $criteria)
126
+    public function addCriteria(CriteriaInterface $criteria)
127 127
     {
128 128
         $this->criteria[] = $criteria;
129 129
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      * @param bool $status
136 136
      * @return $this
137 137
      */
138
-    public function skipCriteria( $status = TRUE )
138
+    public function skipCriteria($status = TRUE)
139 139
     {
140 140
         $this->skipCriteria = $status;
141 141
         return $this;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         $this->eagerLoadRelations();
153 153
         $this->applyCriteria();
154
-        $result = $this->model->paginate( $perPage, $columns );
154
+        $result = $this->model->paginate($perPage, $columns);
155 155
 
156 156
         $this->resetScope();
157 157
 
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
      * @param int $currentPage
164 164
      * @return $this
165 165
      */
166
-    public function setCurrentPage( $currentPage )
166
+    public function setCurrentPage($currentPage)
167 167
     {
168
-        \Illuminate\Pagination\Paginator::currentPageResolver(function() use ( $currentPage )
168
+        \Illuminate\Pagination\Paginator::currentPageResolver(function() use ($currentPage)
169 169
         {
170 170
             return $currentPage;
171 171
         });
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function create(array $data)
182 182
     {
183
-        $cleanFields = $this->cleanUnfillableFields( $data );
183
+        $cleanFields = $this->cleanUnfillableFields($data);
184 184
 
185
-        $createdObject = $this->model->create( $cleanFields );
185
+        $createdObject = $this->model->create($cleanFields);
186 186
 
187 187
         $this->resetScope();
188 188
 
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function updateBy(array $data, $value = NULL, $field = 'id')
199 199
     {
200
-        $cleanFields = $this->cleanUnfillableFields( $data );
200
+        $cleanFields = $this->cleanUnfillableFields($data);
201 201
 
202
-        if ( !is_null( $value ) )
202
+        if (!is_null($value))
203 203
         {
204 204
             // Single update.
205
-            $this->model = $this->model->where( $field, $value);
205
+            $this->model = $this->model->where($field, $value);
206 206
 
207
-            foreach( $cleanFields as $F => $V ) $this->model->{$F} = $V;
207
+            foreach ($cleanFields as $F => $V) $this->model->{$F} = $V;
208 208
 
209 209
             $this->model->save();
210 210
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
             // Mass update.
215 215
             $this->applyCriteria();
216 216
 
217
-            $returnedVal = $this->model->update( $cleanFields );
217
+            $returnedVal = $this->model->update($cleanFields);
218 218
         }
219 219
 
220 220
         $this->resetScope();
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
      * @param string $field
228 228
      * @return bool
229 229
      */
230
-    public function delete( $value = null, $field = 'id' )
230
+    public function delete($value = null, $field = 'id')
231 231
     {
232 232
         $this->applyCriteria();
233 233
 
234
-        if ( !is_null( $value ) ) $result = $this->model->where( $field, $value )->delete();
234
+        if (!is_null($value)) $result = $this->model->where($field, $value)->delete();
235 235
         else
236 236
         {
237
-            if ( !empty( $this->criteria ) ) $result = $this->model->delete();
237
+            if (!empty($this->criteria)) $result = $this->model->delete();
238 238
             else $result = FALSE;
239 239
         }
240 240
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     public function resetScope()
263 263
     {
264 264
         $this->criteria = [];
265
-        $this->skipCriteria( FALSE );
265
+        $this->skipCriteria(FALSE);
266 266
         $this->model = new $this->modelClassName();
267 267
         return $this;
268 268
     }
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
     {
277 277
         $this->applyCriteria();
278 278
 
279
-        if ( !is_null( $value ) ) $result = $this->model->where( $field, $value )->forceDelete();
279
+        if (!is_null($value)) $result = $this->model->where($field, $value)->forceDelete();
280 280
         else
281 281
         {
282
-            if ( !empty( $this->criteria ) ) $result = $this->model->forceDelete();
282
+            if (!empty($this->criteria)) $result = $this->model->forceDelete();
283 283
             else $result = FALSE;
284 284
         }
285 285
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      */
299 299
     protected function eagerLoadRelations()
300 300
     {
301
-        if ( is_array( $this->with ) ) $this->model->with( $this->with );
301
+        if (is_array($this->with)) $this->model->with($this->with);
302 302
     }
303 303
 
304 304
 
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
      * @param array $data
307 307
      * @return array
308 308
      */
309
-    private function cleanUnfillableFields( array $data )
309
+    private function cleanUnfillableFields(array $data)
310 310
     {
311 311
         $fillableFields = $this->model->getFillable();
312 312
 
313
-        foreach( $data as $key => $value )
313
+        foreach ($data as $key => $value)
314 314
         {
315
-            if ( !in_array( $key, $fillableFields ) ) unset( $data[ $key ] );
315
+            if (!in_array($key, $fillableFields)) unset($data[$key]);
316 316
         }
317 317
 
318 318
         return $data;
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
      */
324 324
     private function applyCriteria()
325 325
     {
326
-        if( !$this->skipCriteria )
326
+        if (!$this->skipCriteria)
327 327
         {
328
-            foreach( $this->criteria as $criteria )
328
+            foreach ($this->criteria as $criteria)
329 329
             {
330
-                if( $criteria instanceof CriteriaInterface ) $this->model = $criteria->apply( $this->model, $this );
330
+                if ($criteria instanceof CriteriaInterface) $this->model = $criteria->apply($this->model, $this);
331 331
             }
332 332
         }
333 333
 
Please login to merge, or discard this patch.
Braces   +37 added lines, -15 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
         $this->eagerLoadRelations();
46 46
         $this->applyCriteria();
47 47
 
48
-        if ( !is_null( $value ) ) $this->model = $this->model->where( $field, $value );
48
+        if ( !is_null( $value ) ) {
49
+            $this->model = $this->model->where( $field, $value );
50
+        }
49 51
 
50 52
         $result = $this->model->first( $columns );
51 53
 
@@ -65,7 +67,9 @@  discard block
 block discarded – undo
65 67
         $this->eagerLoadRelations();
66 68
         $this->applyCriteria();
67 69
 
68
-        if ( !is_null( $value ) && !is_null( $field ) ) $this->model = $this->model->where( $field, $value );
70
+        if ( !is_null( $value ) && !is_null( $field ) ) {
71
+            $this->model = $this->model->where( $field, $value );
72
+        }
69 73
 
70 74
         $result = $this->model->get( $columns );
71 75
 
@@ -111,7 +115,9 @@  discard block
 block discarded – undo
111 115
      */
112 116
     public function with( $relations )
113 117
     {
114
-        if ( is_string( $relations ) ) $relations = func_get_args();
118
+        if ( is_string( $relations ) ) {
119
+            $relations = func_get_args();
120
+        }
115 121
 
116 122
         $this->with = $relations;
117 123
 
@@ -204,7 +210,9 @@  discard block
 block discarded – undo
204 210
             // Single update.
205 211
             $this->model = $this->model->where( $field, $value);
206 212
 
207
-            foreach( $cleanFields as $F => $V ) $this->model->{$F} = $V;
213
+            foreach( $cleanFields as $F => $V ) {
214
+                $this->model->{$F} = $V;
215
+            }
208 216
 
209 217
             $this->model->save();
210 218
 
@@ -231,11 +239,15 @@  discard block
 block discarded – undo
231 239
     {
232 240
         $this->applyCriteria();
233 241
 
234
-        if ( !is_null( $value ) ) $result = $this->model->where( $field, $value )->delete();
235
-        else
242
+        if ( !is_null( $value ) ) {
243
+            $result = $this->model->where( $field, $value )->delete();
244
+        } else
236 245
         {
237
-            if ( !empty( $this->criteria ) ) $result = $this->model->delete();
238
-            else $result = FALSE;
246
+            if ( !empty( $this->criteria ) ) {
247
+                $result = $this->model->delete();
248
+            } else {
249
+                $result = FALSE;
250
+            }
239 251
         }
240 252
 
241 253
         $this->resetScope();
@@ -276,11 +288,15 @@  discard block
 block discarded – undo
276 288
     {
277 289
         $this->applyCriteria();
278 290
 
279
-        if ( !is_null( $value ) ) $result = $this->model->where( $field, $value )->forceDelete();
280
-        else
291
+        if ( !is_null( $value ) ) {
292
+            $result = $this->model->where( $field, $value )->forceDelete();
293
+        } else
281 294
         {
282
-            if ( !empty( $this->criteria ) ) $result = $this->model->forceDelete();
283
-            else $result = FALSE;
295
+            if ( !empty( $this->criteria ) ) {
296
+                $result = $this->model->forceDelete();
297
+            } else {
298
+                $result = FALSE;
299
+            }
284 300
         }
285 301
 
286 302
         $this->resetScope();
@@ -298,7 +314,9 @@  discard block
 block discarded – undo
298 314
      */
299 315
     protected function eagerLoadRelations()
300 316
     {
301
-        if ( is_array( $this->with ) ) $this->model->with( $this->with );
317
+        if ( is_array( $this->with ) ) {
318
+            $this->model->with( $this->with );
319
+        }
302 320
     }
303 321
 
304 322
 
@@ -312,7 +330,9 @@  discard block
 block discarded – undo
312 330
 
313 331
         foreach( $data as $key => $value )
314 332
         {
315
-            if ( !in_array( $key, $fillableFields ) ) unset( $data[ $key ] );
333
+            if ( !in_array( $key, $fillableFields ) ) {
334
+                unset( $data[ $key ] );
335
+            }
316 336
         }
317 337
 
318 338
         return $data;
@@ -327,7 +347,9 @@  discard block
 block discarded – undo
327 347
         {
328 348
             foreach( $this->criteria as $criteria )
329 349
             {
330
-                if( $criteria instanceof CriteriaInterface ) $this->model = $criteria->apply( $this->model, $this );
350
+                if( $criteria instanceof CriteriaInterface ) {
351
+                    $this->model = $criteria->apply( $this->model, $this );
352
+                }
331 353
             }
332 354
         }
333 355
 
Please login to merge, or discard this patch.