File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414
1515final class PetRepository implements RepositoryInterface
1616{
17+ private const string TYPE_ERROR_PATTERN = '%s() expects parameter 1 to be %s, %s given ' ;
18+
1719 public function __construct (private readonly EntityManager $ entityManager ) {}
1820
1921 /**
@@ -24,7 +26,7 @@ public function resolveCollection(CollectionInterface $petCollection): void
2426 if (!$ petCollection instanceof PetCollection) {
2527 throw new \TypeError (
2628 \sprintf (
27- ' %s() expects parameter 1 to be %s, %s given ' ,
29+ self :: TYPE_ERROR_PATTERN ,
2830 __METHOD__ ,
2931 PetCollection::class,
3032 $ petCollection ::class
@@ -73,7 +75,7 @@ public function persist(ModelInterface $pet): void
7375 if (!$ pet instanceof Pet) {
7476 throw new \TypeError (
7577 \sprintf (
76- ' %s() expects parameter 1 to be %s, %s given ' ,
78+ self :: TYPE_ERROR_PATTERN ,
7779 __METHOD__ ,
7880 Pet::class,
7981 $ pet ::class
@@ -89,7 +91,7 @@ public function remove(ModelInterface $pet): void
8991 if (!$ pet instanceof Pet) {
9092 throw new \TypeError (
9193 \sprintf (
92- ' %s() expects parameter 1 to be %s, %s given ' ,
94+ self :: TYPE_ERROR_PATTERN ,
9395 __METHOD__ ,
9496 Pet::class,
9597 $ pet ::class
You can’t perform that action at this time.
0 commit comments