Skip to content

Commit 790a6a9

Browse files
committed
Type hint CopyrightFactory::make()
1 parent a264cd5 commit 790a6a9

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/CopyrightFactory.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff 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)

src/RecordFactory.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)