-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from cycle/refactoring-facade
chore: refactor Facade, simplify exceptions range
- Loading branch information
Showing
5 changed files
with
71 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
} | ||
}, | ||
"minCoveredMsi": 70, | ||
"minMsi": 70, | ||
"minMsi": 55, | ||
"phpUnit": { | ||
"configDir": "./" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,6 @@ | |
use Cycle\ORM\RepositoryInterface; | ||
use Cycle\ORM\Select; | ||
use Cycle\ORM\Transaction\StateInterface; | ||
use Psr\Container\ContainerExceptionInterface; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
use Throwable; | ||
|
||
/** | ||
|
@@ -21,9 +19,6 @@ abstract class ActiveRecord | |
{ | ||
/** | ||
* Finds a single record based on the given primary key. | ||
* | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
*/ | ||
final public static function find(mixed $primaryKey): ?static | ||
{ | ||
|
@@ -35,9 +30,6 @@ final public static function find(mixed $primaryKey): ?static | |
|
||
/** | ||
* Finds a single record based on the given scope. | ||
* | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
*/ | ||
final public static function findOne(array $scope = []): ?static | ||
{ | ||
|
@@ -49,9 +41,6 @@ final public static function findOne(array $scope = []): ?static | |
|
||
/** | ||
* Finds all records based on the given scope. | ||
* | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
*/ | ||
final public static function findAll(array $scope = []): iterable | ||
{ | ||
|
@@ -61,9 +50,6 @@ final public static function findAll(array $scope = []): iterable | |
/** | ||
* Returns a Select query builder for the extending entity class. | ||
* | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
* | ||
* @return Select<TEntity> | ||
*/ | ||
final public static function query(): Select | ||
|
@@ -74,19 +60,11 @@ final public static function query(): Select | |
return $select; | ||
} | ||
|
||
/** | ||
* @throws NotFoundExceptionInterface | ||
* @throws ContainerExceptionInterface | ||
*/ | ||
private static function getRepository(): RepositoryInterface | ||
{ | ||
return self::getOrm()->getRepository(static::class); | ||
} | ||
|
||
/** | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
*/ | ||
private static function getOrm(): ORMInterface | ||
{ | ||
return Facade::getOrm(); | ||
|
@@ -95,8 +73,6 @@ private static function getOrm(): ORMInterface | |
/** | ||
* Persists the current entity. | ||
* | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
* @throws Throwable | ||
*/ | ||
final public function save(bool $cascade = true): StateInterface | ||
Check warning on line 78 in src/ActiveRecord.php
|
||
|
@@ -111,8 +87,6 @@ final public function save(bool $cascade = true): StateInterface | |
/** | ||
* Persists the current entity and throws an exception if an error occurs. | ||
* | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
* @throws Throwable | ||
*/ | ||
final public function saveOrFail(bool $cascade = true): StateInterface | ||
Check warning on line 92 in src/ActiveRecord.php
|
||
|
@@ -124,18 +98,12 @@ final public function saveOrFail(bool $cascade = true): StateInterface | |
return $entityManager->run(); | ||
} | ||
|
||
/** | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
*/ | ||
final public function persist(bool $cascade = true): EntityManagerInterface | ||
Check warning on line 101 in src/ActiveRecord.php
|
||
{ | ||
return Facade::getEntityManager()->persist($this, $cascade); | ||
} | ||
|
||
/** | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
* @throws Throwable | ||
*/ | ||
final public function delete(bool $cascade = true): StateInterface | ||
Check warning on line 109 in src/ActiveRecord.php
|
||
|
@@ -148,9 +116,7 @@ final public function delete(bool $cascade = true): StateInterface | |
} | ||
|
||
/** | ||
* @throws ContainerExceptionInterface | ||
* @throws Throwable | ||
* @throws NotFoundExceptionInterface | ||
*/ | ||
final public function deleteOrFail(bool $cascade = true): StateInterface | ||
{ | ||
|
@@ -163,9 +129,6 @@ final public function deleteOrFail(bool $cascade = true): StateInterface | |
|
||
/** | ||
* Prepares the current entity for deletion. | ||
* | ||
* @throws ContainerExceptionInterface | ||
* @throws NotFoundExceptionInterface | ||
*/ | ||
final public function remove(bool $cascade = true): EntityManagerInterface | ||
Check warning on line 133 in src/ActiveRecord.php
|
||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters