File tree Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 55
66use Articulate \Concise \Contracts \EntityMapper ;
77use Articulate \Concise \Contracts \Repository ;
8- use Closure ;
98use Illuminate \Contracts \Foundation \Application ;
109use Illuminate \Database \DatabaseManager ;
1110use InvalidArgumentException ;
@@ -226,8 +225,8 @@ public function repository(string $class): Repository
226225 $ repository = $ this ->repositories [$ class ] ?? null ;
227226
228227 if ($ repository !== null ) {
229- return $ repository ;
230228 /** @phpstan-ignore return.type */
229+ return $ repository ;
231230 }
232231
233232 $ repositoryClass = $ mapper ->repository ();
Original file line number Diff line number Diff line change @@ -18,13 +18,22 @@ public function register(): void
1818 $ this ->booted ($ this ->registerRepositories (...));
1919 }
2020
21+ /**
22+ * @param \Articulate\Concise\Concise $concise
23+ *
24+ * @return void
25+ */
2126 protected function registerRepositories (Concise $ concise ): void
2227 {
23- foreach ($ concise ->getEntityMappers () as $ mapper ) {
28+ /**
29+ * @var class-string $entity
30+ * @var \Articulate\Concise\Contracts\EntityMapper<*> $mapper
31+ */
32+ foreach ($ concise ->getEntityMappers () as $ entity => $ mapper ) {
2433 $ repo = $ mapper ->repository ();
2534
2635 if ($ repo !== null ) {
27- $ this ->app ->bind ($ repo , fn () => $ concise ->repository ($ mapper -> getClass () ));
36+ $ this ->app ->bind ($ repo , fn () => $ concise ->repository ($ entity ));
2837 }
2938 }
3039 }
Original file line number Diff line number Diff line change @@ -107,6 +107,16 @@ protected function hydrate(?array $data): ?object
107107 */
108108 protected function hydrateMany (Collection $ collection ): Collection
109109 {
110- return $ collection ->map (fn (array $ data ) => $ this ->hydrate ($ data ));
110+ $ newCollection = new Collection ();
111+
112+ foreach ($ collection as $ data ) {
113+ $ entity = $ this ->hydrate ($ data );
114+
115+ if ($ entity !== null ) {
116+ $ newCollection ->push ($ entity );
117+ }
118+ }
119+
120+ return $ newCollection ;
111121 }
112122}
Original file line number Diff line number Diff line change 88
99abstract class MapperServiceProvider extends ServiceProvider
1010{
11+ /**
12+ * @var array<class-string, class-string<\Articulate\Concise\Contracts\EntityMapper<*>>>
13+ */
1114 protected array $ mappers = [];
1215
1316 public function register (): void
You can’t perform that action at this time.
0 commit comments