File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,15 @@ class CopyrightFactory
99 /** @var Copyright[] */
1010 private array $ cache = [];
1111
12- public function make (mixed $ data ): ?Copyright // TODO!
12+ /**
13+ * @param array{
14+ * notice?: mixed,
15+ * license?: mixed,
16+ * license_url?: mixed
17+ * } $data
18+ */
19+ public function make (array $ data ): ?Copyright
1320 {
14- if (! is_array ($ data )) {
15- return null ;
16- }
17-
1821 $ key = hash (
1922 'xxh3 ' ,
2023 json_encode ($ data , JSON_THROW_ON_ERROR )
Original file line number Diff line number Diff line change @@ -113,9 +113,15 @@ private function makeReferences(array $data): array
113113 */
114114 private function makeCopyrights (array $ data ): array
115115 {
116+ $ rawCopyrights = $ data ['copyrights ' ] ?? null ;
117+ if (! is_array ($ rawCopyrights )) {
118+ return [];
119+ }
120+ $ rawCopyrights = array_filter ($ rawCopyrights , static fn (mixed $ s ) => is_array ($ s ));
121+
116122 $ copyrights = array_map (
117- fn (mixed $ datum ): ?Copyright => $ this ->copyrightFactory ->make ($ datum ),
118- ( array ) ( $ data [ ' copyrights ' ] ?? []) ,
123+ fn (array $ datum ): ?Copyright => $ this ->copyrightFactory ->make ($ datum ),
124+ $ rawCopyrights ,
119125 );
120126 $ copyrights = array_filter ($ copyrights );
121127
You can’t perform that action at this time.
0 commit comments