Skip to content

Commit

Permalink
refactor: simplify campo keys fromHis method
Browse files Browse the repository at this point in the history
Co-authored-by: Philipp Bammes <[email protected]>
  • Loading branch information
amiut and tyrann0us authored May 23, 2024
1 parent 94c9b80 commit 2c43e60
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/Domain/CampoKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,13 @@ public static function fromArray(array $map): self
public static function fromHisCode(string $hisCode): self
{
$parts = explode(self::HIS_CODE_DELIMITER, $hisCode);
$map = [];
$map = [
DegreeProgram::DEGREE => $parts[0] ?? null,
DegreeProgram::AREA_OF_STUDY => $parts[1] ?? null,
DegreeProgram::LOCATION => $parts[6] ?? null,
];

if (isset($parts[0])) {
$map[DegreeProgram::DEGREE] = $parts[0];
}

if (isset($parts[1])) {
$map[DegreeProgram::AREA_OF_STUDY] = $parts[1];
}

if (isset($parts[6])) {
$map[DegreeProgram::LOCATION] = $parts[6];
}

return new self($map);
return new self(array_filter($map, fn($value) => !is_null($value)));
}

/**
Expand Down

0 comments on commit 2c43e60

Please sign in to comment.