Completed
Push — master ( e751dd...654533 )
by Alexander
03:00
created
src/Adjustable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
      * @param  array $changes
13 13
      * @return Adjustment
14 14
      */
15
-    public function adjust( array $changes );
15
+    public function adjust(array $changes);
16 16
 
17 17
     /**
18 18
      * Fill the model instance with the adjusted values, replacing the original values.
Please login to merge, or discard this patch.
src/AdjusterServiceProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function boot()
22 22
     {
23
-        $this->publishes( [ __DIR__ . '/../resources/config/adjuster.php' => config_path( 'adjuster.php' ) ], 'config' );
24
-        $this->publishes( [ __DIR__ . '/../resources/migrations' => database_path( 'migrations' ), ], 'migrations' );
23
+        $this->publishes([ __DIR__ . '/../resources/config/adjuster.php' => config_path('adjuster.php') ], 'config');
24
+        $this->publishes([ __DIR__ . '/../resources/migrations' => database_path('migrations'), ], 'migrations');
25 25
     }
26 26
 
27 27
     /**
@@ -31,6 +31,6 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function register()
33 33
     {
34
-        $this->mergeConfigFrom( __DIR__ . '/../resources/config/adjuster.php', 'adjuster' );
34
+        $this->mergeConfigFrom(__DIR__ . '/../resources/config/adjuster.php', 'adjuster');
35 35
     }
36 36
 }
37 37
\ No newline at end of file
Please login to merge, or discard this patch.
src/HasAdjustments.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
      */
22 22
     protected static function bootHasAdjustments()
23 23
     {
24
-        static::saving( function ( Adjustable $model ) {
25
-            if ( $model->isAdjusted() && $model->hasSaveProtection() ) {
24
+        static::saving(function(Adjustable $model) {
25
+            if ($model->isAdjusted() && $model->hasSaveProtection()) {
26 26
                 throw new ModelAdjustedException();
27 27
             }
28 28
         } );
@@ -36,22 +36,22 @@  discard block
 block discarded – undo
36 36
      * @param  array $changes
37 37
      * @return Adjustment
38 38
      */
39
-    public function adjust( array $changes )
39
+    public function adjust(array $changes)
40 40
     {
41
-        $adjustment = Adjustment::firstOrNew( [
42
-            config( 'adjuster.adjustable_column' ) . '_id'   => $this->{$this->getKeyName()},
43
-            config( 'adjuster.adjustable_column' ) . '_type' => $this->getMorphClass()
44
-        ] );
41
+        $adjustment = Adjustment::firstOrNew([
42
+            config('adjuster.adjustable_column') . '_id'   => $this->{$this->getKeyName()},
43
+            config('adjuster.adjustable_column') . '_type' => $this->getMorphClass()
44
+        ]);
45 45
 
46
-        $oldChanges = collect( $adjustment->{config( 'adjuster.changes_column' )} );
47
-        $changes = $oldChanges->merge( $changes )->filter( function ( $value, $key ) {
48
-            return ! is_null( $value ) && $this->$key !== $value;
46
+        $oldChanges = collect($adjustment->{config('adjuster.changes_column')} );
47
+        $changes = $oldChanges->merge($changes)->filter(function($value, $key) {
48
+            return ! is_null($value) && $this->$key !== $value;
49 49
         } );
50 50
 
51
-        if ( $changes->isEmpty() ) {
51
+        if ($changes->isEmpty()) {
52 52
             $adjustment->delete();
53 53
         } else {
54
-            $adjustment->{config( 'adjuster.changes_column' )} = $changes->toJson();
54
+            $adjustment->{config('adjuster.changes_column')} = $changes->toJson();
55 55
             $adjustment->save();
56 56
         }
57 57
 
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function applyAdjustments()
67 67
     {
68
-        $changes = $this->adjustment->{config( 'adjuster.changes_column' )} ?? null;
68
+        $changes = $this->adjustment->{config('adjuster.changes_column')} ?? null;
69 69
 
70
-        if ( is_null( $changes ) ) {
70
+        if (is_null($changes)) {
71 71
             return;
72 72
         }
73 73
 
74
-        $this->fill( $changes );
74
+        $this->fill($changes);
75 75
 
76 76
         $this->adjusted = true;
77 77
     }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function hasSaveProtection()
96 96
     {
97
-        return $this->saveProtection ?? config( 'adjuster.save_protection' );
97
+        return $this->saveProtection ?? config('adjuster.save_protection');
98 98
     }
99 99
 
100 100
     /**
@@ -104,6 +104,6 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function adjustment()
106 106
     {
107
-        return $this->morphOne( config( 'adjuster.adjustment_model' ), config( 'adjuster.adjustable_column' ) );
107
+        return $this->morphOne(config('adjuster.adjustment_model'), config('adjuster.adjustable_column'));
108 108
     }
109 109
 }
110 110
\ No newline at end of file
Please login to merge, or discard this patch.
src/ModelAdjustedException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@
 block discarded – undo
11 11
      *
12 12
      * @param string $message
13 13
      */
14
-    public function __construct( $message = null )
14
+    public function __construct($message = null)
15 15
     {
16
-        parent::__construct( $message ?: 'You cannot persist a model with applied adjustments and save protection enabled' );
16
+        parent::__construct($message ?: 'You cannot persist a model with applied adjustments and save protection enabled');
17 17
     }
18 18
 }
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
src/Adjustment.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@
 block discarded – undo
39 39
      *
40 40
      * @return \Illuminate\Database\Eloquent\Relations\HasMany
41 41
      */
42
-    public function getChangesAttribute( $changes )
42
+    public function getChangesAttribute($changes)
43 43
     {
44
-        return json_decode( $changes, true );
44
+        return json_decode($changes, true);
45 45
     }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
resources/migrations/2016_06_10_015053_create_adjustments_table.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
      */
13 13
     public function up()
14 14
     {
15
-        Schema::create( 'adjustments', function ( Blueprint $table ) {
16
-            $table->increments( 'id' );
17
-            $table->morphs( 'adjustable' );
18
-            $table->json( 'changes' );
15
+        Schema::create('adjustments', function(Blueprint $table) {
16
+            $table->increments('id');
17
+            $table->morphs('adjustable');
18
+            $table->json('changes');
19 19
         } );
20 20
     }
21 21
 
@@ -26,6 +26,6 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function down()
28 28
     {
29
-        Schema::drop( 'adjustments' );
29
+        Schema::drop('adjustments');
30 30
     }
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.