File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 55
66use Illuminate \Database \Eloquent \Model ;
77use Illuminate \Support \Facades \Request ;
8+ use InvalidArgumentException ;
89use Sourcetoad \Logger \Enums \ActivityType ;
910use Sourcetoad \Logger \Enums \HttpVerb ;
1011use Sourcetoad \Logger \Models \AuditActivity ;
@@ -181,11 +182,19 @@ public static function getNumericMorphMap(Model $model): int
181182 $ morphableTypeId = array_search ($ fcqn , $ morphMap , true );
182183 }
183184
184- if (is_numeric ($ morphableTypeId )) {
185- return $ morphableTypeId ;
185+ if (!is_numeric ($ morphableTypeId )) {
186+ throw new InvalidArgumentException (
187+ sprintf ('%s has no numeric model map. Check `morphs` in Logger. ' , get_class ($ model )),
188+ );
186189 }
187190
188- throw new \InvalidArgumentException (get_class ($ model ) . " has no numeric model map. Check `morphs` in Logger. " );
191+ if ($ morphableTypeId === 0 ) {
192+ throw new InvalidArgumentException (
193+ sprintf ('0 is not a valid morph map key for %s. Check `morphs` in Logger. ' , get_class ($ model )),
194+ );
195+ }
196+
197+ return $ morphableTypeId ;
189198 }
190199
191200 private function getHttpVerb (string $ verb ): int
You can’t perform that action at this time.
0 commit comments