From d6eb22d748f8e09987a31b09f7386f2f949f89d1 Mon Sep 17 00:00:00 2001 From: LinaKind Date: Wed, 11 Dec 2024 10:52:40 +0000 Subject: [PATCH] Reduce duplication in the new class https://github.com/elifesciences/issues/issues/9034 --- src/ViewModel/Converter/TeaserTermsBuilder.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ViewModel/Converter/TeaserTermsBuilder.php b/src/ViewModel/Converter/TeaserTermsBuilder.php index 88bd4e50..e21edc35 100644 --- a/src/ViewModel/Converter/TeaserTermsBuilder.php +++ b/src/ViewModel/Converter/TeaserTermsBuilder.php @@ -10,17 +10,17 @@ class TeaserTermsBuilder { public function build(ElifeAssessment $elifeAssessment) { + $buildTermWithCorrectCasing = function (string $termValue) { + return new ViewModel\Term(ucfirst($termValue)); + }; + $significance = array_map( - function ($significanceValue) { - return new ViewModel\Term(ucfirst($significanceValue)); - }, + $buildTermWithCorrectCasing, $elifeAssessment->getSignificance() ?? [] ); $strength = array_map( - function ($strengthValue) { - return new ViewModel\Term(ucfirst($strengthValue)); - }, + $buildTermWithCorrectCasing, $elifeAssessment->getStrength() ?? [] ); return new TeaserTerms(array_merge($significance, $strength));