Passed
Push — master ( c1bd78...130d27 )
by Jesús
01:50
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/MakeCriteriaCommand.php 2 patches
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.
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.
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.
Criteria/CriteriaInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,5 +14,5 @@
 block discarded – undo
14 14
      * @param mixed $queryBuilder Current query builder.
15 15
      * @return mixed $queryBuilder Current instance of the query builder with the criteria appplied.
16 16
      */
17
-    public function apply( $queryBuilder );
17
+    public function apply($queryBuilder);
18 18
 }
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
Criteria/Eloquent/FilterByColumns.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * @param array $filter
18 18
      */
19
-    public function __construct( array $filter )
19
+    public function __construct(array $filter)
20 20
     {
21 21
         $this->filter = $filter;
22 22
     }
@@ -26,26 +26,26 @@  discard block
 block discarded – undo
26 26
      * @param $modelOrBuilder
27 27
      * @return mixed
28 28
      */
29
-    public function apply( $modelOrBuilder )
29
+    public function apply($modelOrBuilder)
30 30
     {
31
-        foreach( $this->filter as $filter )
31
+        foreach ($this->filter as $filter)
32 32
         {
33
-            $nElements = count( $filter );
33
+            $nElements = count($filter);
34 34
 
35 35
             // Apply filter based on then number of items in the array.
36
-            if ( $nElements === 2 )
36
+            if ($nElements === 2)
37 37
             {
38 38
                 $column = $filter[0];
39 39
                 $operation = NULL;
40 40
                 $value = $filter[1];
41
-            } else if ( $nElements === 3 )
41
+            } else if ($nElements === 3)
42 42
             {
43 43
                 $column = $filter[0];
44 44
                 $operation = $filter[1];
45 45
                 $value = $filter[2];
46 46
             } else continue;
47 47
 
48
-            $modelOrBuilder = $this->applyFilter( $modelOrBuilder, $column, $value, $operation );
48
+            $modelOrBuilder = $this->applyFilter($modelOrBuilder, $column, $value, $operation);
49 49
         }
50 50
 
51 51
         return $modelOrBuilder;
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
      * @param $value
59 59
      * @param null $operation
60 60
      */
61
-    private function applyFilter( $modelOrBuilder, $column, $value, $operation = NULL )
61
+    private function applyFilter($modelOrBuilder, $column, $value, $operation = NULL)
62 62
     {
63
-        if ( is_null( $operation ) ) $modelOrBuilder = $modelOrBuilder->where( $column, $value );
64
-        else $modelOrBuilder = $modelOrBuilder->where( $column, $operation, $value );
63
+        if (is_null($operation)) $modelOrBuilder = $modelOrBuilder->where($column, $value);
64
+        else $modelOrBuilder = $modelOrBuilder->where($column, $operation, $value);
65 65
 
66 66
         return $modelOrBuilder;
67 67
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
                 $column = $filter[0];
44 44
                 $operation = $filter[1];
45 45
                 $value = $filter[2];
46
-            } else continue;
46
+            } else {
47
+                continue;
48
+            }
47 49
 
48 50
             $modelOrBuilder = $this->applyFilter( $modelOrBuilder, $column, $value, $operation );
49 51
         }
@@ -60,8 +62,11 @@  discard block
 block discarded – undo
60 62
      */
61 63
     private function applyFilter( $modelOrBuilder, $column, $value, $operation = NULL )
62 64
     {
63
-        if ( is_null( $operation ) ) $modelOrBuilder = $modelOrBuilder->where( $column, $value );
64
-        else $modelOrBuilder = $modelOrBuilder->where( $column, $operation, $value );
65
+        if ( is_null( $operation ) ) {
66
+            $modelOrBuilder = $modelOrBuilder->where( $column, $value );
67
+        } else {
68
+            $modelOrBuilder = $modelOrBuilder->where( $column, $operation, $value );
69
+        }
65 70
 
66 71
         return $modelOrBuilder;
67 72
     }
Please login to merge, or discard this patch.