Skip to content

Commit 2abe0dc

Browse files
committed
Formatting ISBN with hyphen
Issue: documentacao-e-tarefas/desenvolvimento_e_infra#1002 Signed-off-by: Thiago Brasil <thiago@lepidus.com.br>
1 parent 6c85140 commit 2abe0dc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

classes/factories/ThothPublicationFactory.inc.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ private function getIsbnByPublicationFormat($publicationFormat)
7272
$identificationCodes = $publicationFormat->getIdentificationCodes()->toArray();
7373
foreach ($identificationCodes as $identificationCode) {
7474
if ($identificationCode->getCode() == '15' || $identificationCode->getCode() == '24') {
75-
return $identificationCode->getValue();
75+
$isbn = $identificationCode->getValue();
76+
try {
77+
$isbn13 = \Biblys\Isbn\Isbn::convertToIsbn13($isbn);
78+
return str_replace('-', '', $isbn13) === $isbn ? $isbn13 : $isbn;
79+
} catch (Exception $e) {
80+
return $isbn;
81+
}
7682
}
7783
}
7884

0 commit comments

Comments
 (0)