44
55namespace CalebDW \SqlEntities ;
66
7- use CalebDW \SqlEntities \Entities \ Entity ;
7+ use CalebDW \SqlEntities \SqlEntity ;
88use CalebDW \SqlEntities \Grammars \Grammar ;
99use CalebDW \SqlEntities \Grammars \PostgresGrammar ;
1010use CalebDW \SqlEntities \Grammars \SQLiteGrammar ;
1313use Illuminate \Support \Collection ;
1414use InvalidArgumentException ;
1515
16- class EntityManager
16+ class SqlEntityManager
1717{
1818 /**
1919 * The active grammar instances.
@@ -23,17 +23,17 @@ class EntityManager
2323 protected array $ grammars = [];
2424
2525 public function __construct (
26- /** @var Collection<int, Entity > */
26+ /** @var Collection<int, SqlEntity > */
2727 public readonly Collection $ entities ,
2828 protected DatabaseManager $ db ,
2929 ) {
3030 }
3131
3232 /** @throws InvalidArgumentException if the entity is not found. */
33- public function get (string $ name , ?string $ connection = null ): Entity
33+ public function get (string $ name , ?string $ connection = null ): SqlEntity
3434 {
3535 $ entity = $ this ->entities ->firstWhere (
36- fn (Entity $ e ) => $ e ->name () === $ name
36+ fn (SqlEntity $ e ) => $ e ->name () === $ name
3737 && $ e ->connectionName () === $ connection ,
3838 );
3939
@@ -48,18 +48,18 @@ public function get(string $name, ?string $connection = null): Entity
4848 /**
4949 * Create an entity.
5050 *
51- * @param class-string<Entity >|string|Entity $entity The entity name, class, or instance.
51+ * @param class-string<SqlEntity >|string|SqlEntity $entity The entity name, class, or instance.
5252 * @throws InvalidArgumentException if the entity is not found.
5353 */
54- public function create (Entity |string $ entity ): void
54+ public function create (SqlEntity |string $ entity ): void
5555 {
5656 if (is_string ($ entity )) {
5757 $ entity = class_exists ($ entity )
5858 ? resolve ($ entity )
5959 : $ this ->get ($ entity );
6060 }
6161
62- assert ($ entity instanceof Entity );
62+ assert ($ entity instanceof SqlEntity );
6363 $ connection = $ this ->connection ($ entity );
6464
6565 if (! $ entity ->creating ($ connection )) {
@@ -75,18 +75,18 @@ public function create(Entity|string $entity): void
7575 /**
7676 * Drop an entity.
7777 *
78- * @param class-string<Entity >|string|Entity $entity The entity name, class, or instance.
78+ * @param class-string<SqlEntity >|string|SqlEntity $entity The entity name, class, or instance.
7979 * @throws InvalidArgumentException if the entity is not found.
8080 */
81- public function drop (Entity |string $ entity ): void
81+ public function drop (SqlEntity |string $ entity ): void
8282 {
8383 if (is_string ($ entity )) {
8484 $ entity = class_exists ($ entity )
8585 ? resolve ($ entity )
8686 : $ this ->get ($ entity );
8787 }
8888
89- assert ($ entity instanceof Entity );
89+ assert ($ entity instanceof SqlEntity );
9090 $ connection = $ this ->connection ($ entity );
9191
9292 if (! $ entity ->dropping ($ connection )) {
@@ -99,7 +99,7 @@ public function drop(Entity|string $entity): void
9999 $ entity ->dropped ($ connection );
100100 }
101101
102- /** @param class-string<Entity >|null $type */
102+ /** @param class-string<SqlEntity >|null $type */
103103 public function createAll (?string $ type = null , ?string $ connection = null ): void
104104 {
105105 $ this ->entities
@@ -110,7 +110,7 @@ public function createAll(?string $type = null, ?string $connection = null): voi
110110 ->each (fn ($ e ) => $ this ->create ($ e ));
111111 }
112112
113- /** @param class-string<Entity >|null $type */
113+ /** @param class-string<SqlEntity >|null $type */
114114 public function dropAll (?string $ type = null , ?string $ connection = null ): void
115115 {
116116 $ this ->entities
@@ -121,7 +121,7 @@ public function dropAll(?string $type = null, ?string $connection = null): void
121121 ->each (fn ($ e ) => $ this ->drop ($ e ));
122122 }
123123
124- protected function connection (Entity $ entity ): Connection
124+ protected function connection (SqlEntity $ entity ): Connection
125125 {
126126 return $ this ->db ->connection ($ entity ->connectionName ());
127127 }
0 commit comments