Skip to content

Commit

Permalink
chore: improve code readability, update common package
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyian committed Jul 16, 2024
1 parent 3f02e9c commit 8025975
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions src/Infrastructure/Search/FilterableTermsUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,11 @@ private function retrieveParentTermId(
array &$taxonomyCache
): int {

if (!$flatProperty instanceof Degree && !$flatProperty instanceof AdmissionRequirement) {
if (!$this->isHierarchicalProperty($flatProperty)) {
return 0;
}

/** @var AdmissionRequirement|Degree $flatProperty */
$parentProperty = $flatProperty->parent();

if (is_null($parentProperty)) {
Expand Down Expand Up @@ -376,11 +377,12 @@ private function extendPropertiesWithParents(array $flatProperties): array
$properties = [];

foreach ($flatProperties as $flatProperty) {
if (!$flatProperty instanceof Degree && !$flatProperty instanceof AdmissionRequirement) {
if (!$this->isHierarchicalProperty($flatProperty)) {
$properties[] = $flatProperty;
continue;
}

/** @var AdmissionRequirement|Degree $flatProperty */
$sequence = [$flatProperty];
$parent = $flatProperty->parent();

Expand All @@ -395,15 +397,11 @@ private function extendPropertiesWithParents(array $flatProperties): array
return $properties;
}

private function retrieveFirstLevelTerm(Degree|AdmissionRequirement $structure): Degree|AdmissionRequirement
{
$parent = $structure->parent();
while ($parent) {
$structure = $parent;
$parent = $structure->parent();
}
private function isHierarchicalProperty(
MultilingualString|MultilingualLink|AdmissionRequirement|Degree $flatProperty
): bool {

return $structure;
return $flatProperty instanceof Degree || $flatProperty instanceof AdmissionRequirement;
}

private function createTerm(TermData $termData): ?int
Expand Down
1 change: 0 additions & 1 deletion src/Infrastructure/Search/TermData.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public function slug(): string

public function termId(): int
{

return $this->termId;
}

Expand Down

0 comments on commit 8025975

Please sign in to comment.