@@ -45,13 +45,21 @@ public function get(string $name, ?string $connection = null): Entity
4545 return $ entity ;
4646 }
4747
48- /** @throws InvalidArgumentException if the entity is not found. */
48+ /**
49+ * Create an entity.
50+ *
51+ * @param class-string<Entity>|string|Entity $entity The entity name, class, or instance.
52+ * @throws InvalidArgumentException if the entity is not found.
53+ */
4954 public function create (Entity |string $ entity ): void
5055 {
5156 if (is_string ($ entity )) {
52- $ entity = $ this ->get ($ entity );
57+ $ entity = class_exists ($ entity )
58+ ? resolve ($ entity )
59+ : $ this ->get ($ entity );
5360 }
5461
62+ assert ($ entity instanceof Entity);
5563 $ connection = $ this ->connection ($ entity );
5664
5765 if (! $ entity ->creating ($ connection )) {
@@ -64,13 +72,21 @@ public function create(Entity|string $entity): void
6472 $ entity ->created ($ connection );
6573 }
6674
67- /** @throws InvalidArgumentException if the entity is not found. */
75+ /**
76+ * Drop an entity.
77+ *
78+ * @param class-string<Entity>|string|Entity $entity The entity name, class, or instance.
79+ * @throws InvalidArgumentException if the entity is not found.
80+ */
6881 public function drop (Entity |string $ entity ): void
6982 {
7083 if (is_string ($ entity )) {
71- $ entity = $ this ->get ($ entity );
84+ $ entity = class_exists ($ entity )
85+ ? resolve ($ entity )
86+ : $ this ->get ($ entity );
7287 }
7388
89+ assert ($ entity instanceof Entity);
7490 $ connection = $ this ->connection ($ entity );
7591
7692 if (! $ entity ->dropping ($ connection )) {
0 commit comments