@@ -11,9 +11,6 @@ |
||
| 11 | 11 | |
| 12 | 12 | namespace BoxedCode\Eloquent\Meta; |
| 13 | 13 | |
| 14 | -use BoxedCode\Eloquent\Meta\MetaCollection; |
|
| 15 | -use BoxedCode\Eloquent\Meta\Contracts\MetaItem as ItemContract; |
|
| 16 | - |
|
| 17 | 14 | trait Metable |
| 18 | 15 | { |
| 19 | 16 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public static function observeSaveAndCascade() |
| 107 | 107 | { |
| 108 | - $onSave = function ($model) { |
|
| 108 | + $onSave = function($model) { |
|
| 109 | 109 | |
| 110 | 110 | /* |
| 111 | 111 | * Remove any keys not present in the collection |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public static function observeDeleteAndCascade() |
| 145 | 145 | { |
| 146 | - $onDelete = function ($model) { |
|
| 146 | + $onDelete = function($model) { |
|
| 147 | 147 | foreach ($model->meta as $meta) { |
| 148 | 148 | $meta->delete(); |
| 149 | 149 | } |
@@ -48,9 +48,7 @@ |
||
| 48 | 48 | { |
| 49 | 49 | if (parent::isDirty($attributes)) { |
| 50 | 50 | return true; |
| 51 | - } |
|
| 52 | - |
|
| 53 | - else { |
|
| 51 | + } else { |
|
| 54 | 52 | foreach ($this->meta as $item) { |
| 55 | 53 | if ($item->isDirty($attributes)) { |
| 56 | 54 | return true; |
@@ -40,6 +40,10 @@ |
||
| 40 | 40 | ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | + /** |
|
| 44 | + * @param string $class |
|
| 45 | + * @param Type $instance |
|
| 46 | + */ |
|
| 43 | 47 | protected function registerClass($class, $instance) |
| 44 | 48 | { |
| 45 | 49 | if (!isset($this->registered[$class])) { |
@@ -25,9 +25,7 @@ |
||
| 25 | 25 | $this->registerClass(get_class($mixed), $mixed); |
| 26 | 26 | |
| 27 | 27 | return true; |
| 28 | - } |
|
| 29 | - |
|
| 30 | - elseif (is_array($mixed)) { |
|
| 28 | + } elseif (is_array($mixed)) { |
|
| 31 | 29 | foreach ($mixed as $type) { |
| 32 | 30 | $this->register($type); |
| 33 | 31 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | public function set($value) |
| 32 | 32 | { |
| 33 | - parent::set(intval($value)); |
|
| 33 | + parent::set(intval($value)); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | */ |
| 92 | 92 | public function setValueAttribute($value, $type = null) |
| 93 | 93 | { |
| 94 | - if (! $type && ! isset($this->attributes['type'])) { |
|
| 94 | + if (!$type && !isset($this->attributes['type'])) { |
|
| 95 | 95 | $registry = $this->getTypeRegistry(); |
| 96 | 96 | $this->type = $registry->findTypeFor($value)->getClass(); |
| 97 | 97 | } |
@@ -94,9 +94,7 @@ |
||
| 94 | 94 | if (! $type && ! isset($this->attributes['type'])) { |
| 95 | 95 | $registry = $this->getTypeRegistry(); |
| 96 | 96 | $this->type = $registry->findTypeFor($value)->getClass(); |
| 97 | - } |
|
| 98 | - |
|
| 99 | - elseif ($type) { |
|
| 97 | + } elseif ($type) { |
|
| 100 | 98 | $this->type = $type; |
| 101 | 99 | } |
| 102 | 100 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | if ($item instanceof ItemContract) { |
| 93 | 93 | |
| 94 | - if (! is_null($this->find($item->key, $item->tag))) { |
|
| 94 | + if (!is_null($this->find($item->key, $item->tag))) { |
|
| 95 | 95 | $tag = $item->tag ?: $this->default_tag; |
| 96 | 96 | |
| 97 | 97 | $key = $item->key; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | $collection = $this->whereKey($key); |
| 120 | 120 | |
| 121 | - if (! is_null($tag)) { |
|
| 121 | + if (!is_null($tag)) { |
|
| 122 | 122 | $collection = $collection->whereTag($tag); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | protected function observeDeletion(ItemContract $item) |
| 150 | 150 | { |
| 151 | - $item::deleted(function ($model) { |
|
| 151 | + $item::deleted(function($model) { |
|
| 152 | 152 | $key = $this->find($model->key, $model->tag); |
| 153 | 153 | |
| 154 | - if (! is_null($key)) { |
|
| 154 | + if (!is_null($key)) { |
|
| 155 | 155 | $this->forget($key); |
| 156 | 156 | } |
| 157 | 157 | }); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function __isset($name) |
| 233 | 233 | { |
| 234 | - return ! is_null($this->find($name, $this->default_tag)); |
|
| 234 | + return !is_null($this->find($name, $this->default_tag)); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | { |
| 244 | 244 | $key = $this->find($name, $this->default_tag); |
| 245 | 245 | |
| 246 | - if (! is_null($key)) { |
|
| 246 | + if (!is_null($key)) { |
|
| 247 | 247 | $this->forget($key); |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | { |
| 260 | 260 | $key = $this->find($name, $this->default_tag); |
| 261 | 261 | |
| 262 | - if (! is_null($key)) { |
|
| 262 | + if (!is_null($key)) { |
|
| 263 | 263 | return $this->get($key)->value; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | { |
| 282 | 282 | $key = $this->find($name, $this->default_tag); |
| 283 | 283 | |
| 284 | - if (! is_null($key)) { |
|
| 284 | + if (!is_null($key)) { |
|
| 285 | 285 | $this->get($key)->value = $value; |
| 286 | 286 | } |
| 287 | 287 | else { |
@@ -283,8 +283,7 @@ |
||
| 283 | 283 | |
| 284 | 284 | if (! is_null($key)) { |
| 285 | 285 | $this->get($key)->value = $value; |
| 286 | - } |
|
| 287 | - else { |
|
| 286 | + } else { |
|
| 288 | 287 | $attr = [ |
| 289 | 288 | 'key' => $name, |
| 290 | 289 | 'value' => $value, |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | return [ |
| 57 | 57 | 'path' => $this->getMigrationPath(), |
| 58 | 58 | 'name' => $name, |
| 59 | - 'table_name' => $name ? $name . '_meta' : 'meta', |
|
| 60 | - 'file_name' => $name ? $name . '_meta_migration' : 'meta_migration', |
|
| 59 | + 'table_name' => $name ? $name.'_meta' : 'meta', |
|
| 60 | + 'file_name' => $name ? $name.'_meta_migration' : 'meta_migration', |
|
| 61 | 61 | ]; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | protected function replacePlaceholders($template, $name, $table_name) |
| 73 | 73 | { |
| 74 | 74 | $replacements = [ |
| 75 | - 'DummyClass' => ucfirst($name) . 'MetaMigration', |
|
| 75 | + 'DummyClass' => ucfirst($name).'MetaMigration', |
|
| 76 | 76 | 'DummyTable' => $table_name, |
| 77 | 77 | ]; |
| 78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | protected function getStub() |
| 88 | 88 | { |
| 89 | - return file_get_contents(__DIR__ . DIRECTORY_SEPARATOR); |
|
| 89 | + return file_get_contents(__DIR__.DIRECTORY_SEPARATOR); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | public function registerTypeRegistry() |
| 49 | 49 | { |
| 50 | - $this->app->singleton(TypeRegistry::class, function () { |
|
| 50 | + $this->app->singleton(TypeRegistry::class, function() { |
|
| 51 | 51 | $registry = new TypeRegistry; |
| 52 | 52 | |
| 53 | 53 | $this->registerDefaultTypes($registry); |