Skip to content

Commit 3c545d3

Browse files
committed
chore: rename Entity to SqlEntity
1 parent 6d395f8 commit 3c545d3

File tree

17 files changed

+68
-68
lines changed

17 files changed

+68
-68
lines changed

src/Entities/View.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Facades/SqlEntity.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
namespace CalebDW\SqlEntities\Facades;
66

7-
use CalebDW\SqlEntities\EntityManager;
7+
use CalebDW\SqlEntities\SqlEntityManager;
88
use Illuminate\Support\Facades\Facade;
99
use Override;
1010

11-
/** @mixin EntityManager */
11+
/** @mixin SqlEntityManager */
1212
class SqlEntity extends Facade
1313
{
1414
#[Override]
1515
protected static function getFacadeAccessor(): string
1616
{
17-
return EntityManager::class;
17+
return SqlEntityManager::class;
1818
}
1919
}

src/Grammars/Grammar.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace CalebDW\SqlEntities\Grammars;
66

7-
use CalebDW\SqlEntities\Entities\Entity;
8-
use CalebDW\SqlEntities\Entities\View;
7+
use CalebDW\SqlEntities\SqlEntity;
8+
use CalebDW\SqlEntities\View;
99
use Illuminate\Database\Connection;
1010
use InvalidArgumentException;
1111

@@ -16,7 +16,7 @@ public function __construct(
1616
) {
1717
}
1818

19-
public function compileCreate(Entity $entity): string
19+
public function compileCreate(SqlEntity $entity): string
2020
{
2121
return match (true) {
2222
$entity instanceof View => $this->compileViewCreate($entity),
@@ -27,7 +27,7 @@ public function compileCreate(Entity $entity): string
2727
};
2828
}
2929

30-
public function compileDrop(Entity $entity): string
30+
public function compileDrop(SqlEntity $entity): string
3131
{
3232
return match (true) {
3333
$entity instanceof View => $this->compileViewDrop($entity),

src/Grammars/PostgresGrammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace CalebDW\SqlEntities\Grammars;
66

7-
use CalebDW\SqlEntities\Entities\View;
7+
use CalebDW\SqlEntities\View;
88
use Override;
99

1010
class PostgresGrammar extends Grammar

src/Grammars/SQLiteGrammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace CalebDW\SqlEntities\Grammars;
66

7-
use CalebDW\SqlEntities\Entities\View;
7+
use CalebDW\SqlEntities\View;
88
use Override;
99

1010
class SQLiteGrammar extends Grammar

src/Listeners/SyncEntities.php renamed to src/Listeners/SyncSqlEntities.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
namespace CalebDW\SqlEntities\Listeners;
66

7-
use CalebDW\SqlEntities\EntityManager;
7+
use CalebDW\SqlEntities\SqlEntityManager;
88
use Illuminate\Database\Events\MigrationsEnded;
99
use Illuminate\Database\Events\MigrationsStarted;
1010

11-
class SyncEntities
11+
class SyncSqlEntities
1212
{
1313
public function __construct(
14-
protected EntityManager $manager,
14+
protected SqlEntityManager $manager,
1515
) {
1616
}
1717

src/ServiceProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace CalebDW\SqlEntities;
66

7-
use CalebDW\SqlEntities\Entities\Entity;
7+
use CalebDW\SqlEntities\SqlEntity;
88
use CalebDW\SqlEntities\Support\Composer;
99
use Illuminate\Contracts\Foundation\Application;
1010
use Illuminate\Contracts\Support\DeferrableProvider;
@@ -19,20 +19,20 @@ class ServiceProvider extends IlluminateServiceProvider implements DeferrablePro
1919
#[Override]
2020
public function provides(): array
2121
{
22-
return [EntityManager::class, 'sql-entities']; // @codeCoverageIgnore
22+
return [SqlEntityManager::class, 'sql-entities']; // @codeCoverageIgnore
2323
}
2424

2525
#[Override]
2626
public function register(): void
2727
{
28-
$this->app->singleton(EntityManager::class, function (Application $app) {
29-
return new EntityManager($this->getEntities($app), $app->make('db'));
28+
$this->app->singleton(SqlEntityManager::class, function (Application $app) {
29+
return new SqlEntityManager($this->getEntities($app), $app->make('db'));
3030
});
3131

32-
$this->app->alias(EntityManager::class, 'sql-entities');
32+
$this->app->alias(SqlEntityManager::class, 'sql-entities');
3333
}
3434

35-
/** @return Collection<int, Entity> */
35+
/** @return Collection<int, SqlEntity> */
3636
private function getEntities(Application $app): Collection
3737
{
3838
$composer = new Composer($app->make('files'), $app->basePath());
@@ -46,7 +46,7 @@ private function getEntities(Application $app): Collection
4646
))
4747
->map(fn ($file) => (string) $file->getRealPath())
4848
->pipe(fn ($files) => collect($composer->classFromFile($files->all())))
49-
->filter(fn ($class) => is_subclass_of($class, Entity::class))
49+
->filter(fn ($class) => is_subclass_of($class, SqlEntity::class))
5050
->map(fn ($class) => $app->make($class))
5151
->values();
5252
}

src/Entities/Entity.php renamed to src/SqlEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace CalebDW\SqlEntities\Entities;
5+
namespace CalebDW\SqlEntities;
66

77
use Illuminate\Database\Connection;
88
use Illuminate\Database\Query\Builder;
99
use Stringable;
1010

11-
abstract class Entity implements Stringable
11+
abstract class SqlEntity implements Stringable
1212
{
1313
/** The entity name. */
1414
abstract public function name(): string;

src/EntityManager.php renamed to src/SqlEntityManager.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace CalebDW\SqlEntities;
66

7-
use CalebDW\SqlEntities\Entities\Entity;
7+
use CalebDW\SqlEntities\SqlEntity;
88
use CalebDW\SqlEntities\Grammars\Grammar;
99
use CalebDW\SqlEntities\Grammars\PostgresGrammar;
1010
use CalebDW\SqlEntities\Grammars\SQLiteGrammar;
@@ -13,7 +13,7 @@
1313
use Illuminate\Support\Collection;
1414
use 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
}

src/View.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CalebDW\SqlEntities;
6+
7+
abstract class View extends SqlEntity
8+
{
9+
}

0 commit comments

Comments
 (0)