diff --git a/src/Entity/Note.php b/src/Entity/Note.php
index be7bde6..bd44a8f 100644
--- a/src/Entity/Note.php
+++ b/src/Entity/Note.php
@@ -67,7 +67,7 @@ class Note
$note->mediaInfo = $note->parseMediaInfo($note->fields['Notes']);
// Set VocabKanji field
- $terms = self::parseVocabDef($note->fields['VocabDef']);
+ $terms = Term::fromVocabDef($note->fields['VocabDef']);
if (null !== $terms) {
$note->terms = $terms;
} else {
@@ -97,7 +97,7 @@ class Note
. $separator
. $note->fields['VocabDef'];
- $terms = self::parseVocabDef($note->fields['VocabDef']);
+ $terms = Term::fromVocabDef($note->fields['VocabDef']);
$note->terms = $terms ?? dd($note->fields['VocabDef']);
}
@@ -161,21 +161,6 @@ class Note
];
}
- public static function parseVocabDef(string $vocabDef): ?array
- {
- if (mb_trim($vocabDef) === '') return null;
-
- $terms = [];
- foreach (preg_split('|
|', $vocabDef) as $line) {
- $term = Term::fromVocabDefLine(strip_tags($line));
- // Error parsing term, can't parse using vocabDef
- if (null === $term) return null;
- $terms[] = $term;
- };
-
- return $terms;
- }
-
public function parseMediaInfo(string $notes): ?array
{
$matches = null;
diff --git a/src/Entity/Term.php b/src/Entity/Term.php
index 78750ff..df8e70d 100644
--- a/src/Entity/Term.php
+++ b/src/Entity/Term.php
@@ -49,7 +49,7 @@ class Term
return $ret;
}
- public static function fromVocabDefLine(string $vocabDefLine): ?Term
+ private static function fromVocabDefLine(string $vocabDefLine): ?Term
{
$term = new Term();
@@ -126,4 +126,19 @@ class Term
dd("Unexpected error, couldn't parse definition line", $vocabDefLine);
}
+
+ public static function fromVocabDef(string $vocabDef): ?array
+ {
+ if (mb_trim($vocabDef) === '') return null;
+
+ $terms = [];
+ foreach (preg_split('|
|', $vocabDef) as $line) {
+ $term = self::fromVocabDefLine(strip_tags($line));
+ // Error parsing term, can't parse using vocabDef
+ if (null === $term) return null;
+ $terms[] = $term;
+ };
+
+ return $terms;
+ }
}