Skip to content

Commit

Permalink
fix(6736) using match instead of in_array
Browse files Browse the repository at this point in the history
  • Loading branch information
amermchaudhary authored Oct 22, 2024
1 parent 3ecb934 commit 616531c
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ public function create(string $resourceClass, string $property, array $options =
continue;
}

$collection = false;
if (\in_array($relation['type'], [HasMany::class, HasManyThrough::class, BelongsToMany::class, MorphMany::class, MorphToMany::class], true)) {
$collection = true;
}
$collection = match($relation['type']) {
HasMany::class,
HasManyThrough::class,
BelongsToMany::class,
MorphMany::class,
MorphToMany::class => true,
default => false
};

$type = new Type($collection ? Type::BUILTIN_TYPE_ITERABLE : Type::BUILTIN_TYPE_OBJECT, false, $relation['related'], $collection, collectionValueType: new Type(Type::BUILTIN_TYPE_OBJECT, false, $relation['related']));

Expand Down

0 comments on commit 616531c

Please sign in to comment.