@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function __construct(string $field, string $stateClass) |
| 23 | 23 | { |
| 24 | - if (! is_subclass_of($stateClass, State::class)) { |
|
| 24 | + if (!is_subclass_of($stateClass, State::class)) { |
|
| 25 | 25 | throw InvalidConfig::doesNotExtendState($stateClass); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -54,15 +54,15 @@ discard block |
||
| 54 | 54 | return $this; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if (! is_subclass_of($from, $this->stateClass)) { |
|
| 57 | + if (!is_subclass_of($from, $this->stateClass)) { |
|
| 58 | 58 | throw InvalidConfig::doesNotExtendBaseClass($from, $this->stateClass); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if (! is_subclass_of($to, $this->stateClass)) { |
|
| 61 | + if (!is_subclass_of($to, $this->stateClass)) { |
|
| 62 | 62 | throw InvalidConfig::doesNotExtendBaseClass($to, $this->stateClass); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ($transition && ! is_subclass_of($transition, Transition::class)) { |
|
| 65 | + if ($transition && !is_subclass_of($transition, Transition::class)) { |
|
| 66 | 66 | throw InvalidConfig::doesNotExtendTransition($transition); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | $transitionKey = $this->createTransitionKey($from, $to); |
| 110 | 110 | |
| 111 | - if (! array_key_exists($transitionKey, $this->allowedTransitions)) { |
|
| 111 | + if (!array_key_exists($transitionKey, $this->allowedTransitions)) { |
|
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public static function bootHasStates(): void |
| 26 | 26 | { |
| 27 | - $serializeState = function (StateConfig $stateConfig) { |
|
| 28 | - return function (Model $model) use ($stateConfig) { |
|
| 27 | + $serializeState = function(StateConfig $stateConfig) { |
|
| 28 | + return function(Model $model) use ($stateConfig) { |
|
| 29 | 29 | $value = $model->getAttribute($stateConfig->field); |
| 30 | 30 | |
| 31 | 31 | if ($value === null) { |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $stateClass = $stateConfig->stateClass::resolveStateClass($value); |
| 40 | 40 | |
| 41 | - if (! is_subclass_of($stateClass, $stateConfig->stateClass)) { |
|
| 41 | + if (!is_subclass_of($stateClass, $stateConfig->stateClass)) { |
|
| 42 | 42 | throw InvalidConfig::fieldDoesNotExtendState( |
| 43 | 43 | $stateConfig->field, |
| 44 | 44 | $stateConfig->stateClass, |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | }; |
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | - $unserializeState = function (StateConfig $stateConfig) { |
|
| 57 | - return function (Model $model) use ($stateConfig) { |
|
| 56 | + $unserializeState = function(StateConfig $stateConfig) { |
|
| 57 | + return function(Model $model) use ($stateConfig) { |
|
| 58 | 58 | $stateClass = $stateConfig->stateClass::resolveStateClass($model->getAttribute($stateConfig->field)); |
| 59 | 59 | |
| 60 | 60 | $defaultState = $stateConfig->defaultStateClass |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | public function initializeHasStates(): void |
| 86 | 86 | { |
| 87 | 87 | foreach (self::getStateConfig() as $stateConfig) { |
| 88 | - if (! $stateConfig->defaultStateClass) { |
|
| 88 | + if (!$stateConfig->defaultStateClass) { |
|
| 89 | 89 | continue; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | /** @var \Spatie\ModelStates\StateConfig|null $stateConfig */ |
| 101 | 101 | $stateConfig = self::getStateConfig()[$field] ?? null; |
| 102 | 102 | |
| 103 | - if (! $stateConfig) { |
|
| 103 | + if (!$stateConfig) { |
|
| 104 | 104 | throw InvalidConfig::unknownState($field, $this); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $abstractStateClass = $stateConfig->stateClass; |
| 108 | 108 | |
| 109 | - $stateNames = collect((array) $states)->map(function ($state) use ($abstractStateClass) { |
|
| 109 | + $stateNames = collect((array) $states)->map(function($state) use ($abstractStateClass) { |
|
| 110 | 110 | return $abstractStateClass::resolveStateName($state); |
| 111 | 111 | }); |
| 112 | 112 | |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | /** @var \Spatie\ModelStates\StateConfig|null $stateConfig */ |
| 121 | 121 | $stateConfig = self::getStateConfig()[$field] ?? null; |
| 122 | 122 | |
| 123 | - if (! $stateConfig) { |
|
| 123 | + if (!$stateConfig) { |
|
| 124 | 124 | throw InvalidConfig::unknownState($field, $this); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $stateNames = collect((array) $states)->map(function ($state) use ($stateConfig) { |
|
| 127 | + $stateNames = collect((array) $states)->map(function($state) use ($stateConfig) { |
|
| 128 | 128 | return $stateConfig->stateClass::resolveStateName($state); |
| 129 | 129 | }); |
| 130 | 130 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $field = $field ?? reset($stateConfig)->field; |
| 162 | 162 | |
| 163 | - if (! array_key_exists($field, $stateConfig)) { |
|
| 163 | + if (!array_key_exists($field, $stateConfig)) { |
|
| 164 | 164 | throw InvalidConfig::unknownState($field, $this); |
| 165 | 165 | } |
| 166 | 166 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | public static function getStates(): Collection |
| 243 | 243 | { |
| 244 | 244 | return collect(static::getStateConfig()) |
| 245 | - ->map(function ($state) { |
|
| 245 | + ->map(function($state) { |
|
| 246 | 246 | return $state->stateClass::all(); |
| 247 | 247 | }); |
| 248 | 248 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | public static function getDefaultStates(): Collection |
| 256 | 256 | { |
| 257 | 257 | return collect(static::getStateConfig()) |
| 258 | - ->map(function ($state) { |
|
| 258 | + ->map(function($state) { |
|
| 259 | 259 | return $state->defaultStateClass; |
| 260 | 260 | }); |
| 261 | 261 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $stateClass = static::resolveStateClass($name); |
| 44 | 44 | |
| 45 | - if (! is_subclass_of($stateClass, static::class)) { |
|
| 45 | + if (!is_subclass_of($stateClass, static::class)) { |
|
| 46 | 46 | throw InvalidConfig::doesNotExtendBaseClass($name, static::class); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | foreach (self::resolveStateMapping() as $stateClass) { |
| 114 | - if (! class_exists($stateClass)) { |
|
| 114 | + if (!class_exists($stateClass)) { |
|
| 115 | 115 | continue; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | if (method_exists($transition, 'canTransition')) { |
| 228 | - if (! $transition->canTransition()) { |
|
| 228 | + if (!$transition->canTransition()) { |
|
| 229 | 229 | throw CouldNotPerformTransition::notAllowed($this->model, $transition); |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | $finalState = $mutatedModel->state; |
| 244 | 244 | |
| 245 | - if (! $finalState instanceof State) { |
|
| 245 | + if (!$finalState instanceof State) { |
|
| 246 | 246 | $finalState = null; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public function transitionTo($state, ...$args): Model |
| 261 | 261 | { |
| 262 | - if (! method_exists($this->model, 'resolveTransitionClass')) { |
|
| 262 | + if (!method_exists($this->model, 'resolveTransitionClass')) { |
|
| 263 | 263 | throw InvalidConfig::resolveTransitionNotFound($this->model); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | $stateClass = $namespace.'\\'.$className; |
| 323 | 323 | |
| 324 | - if (! is_subclass_of($stateClass, static::class)) { |
|
| 324 | + if (!is_subclass_of($stateClass, static::class)) { |
|
| 325 | 325 | continue; |
| 326 | 326 | } |
| 327 | 327 | |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | public function getTo(): string |
| 48 | 48 | { |
| 49 | - return $this->to; |
|
| 49 | + return $this->to; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function setModelClass(string $modelClass): self |