-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FAU-414] Add support for campo keys #7
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0ec4447
feat: add campo keys to degree program
amiut a2be742
style: fix QA errors and warnings
amiut 4a72cba
chore: remove not reproducible to-do comment
amiut ad01d50
chore: remove unnecessary getters and setters from CampoKeys DO
amiut 0816b3a
chore: rename constants
amiut 94c9b80
refactor: throw exception instead of passing invalid term id, when te…
amiut 2c43e60
refactor: simplify campo keys fromHis method
amiut bc49aab
Merge branch 'dev' into FAU-414
amiut df7cbd3
refactor: move campo keys schema to common package
amiut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Fau\DegreeProgram\Common\Domain; | ||
|
||
/** | ||
* @psalm-type CampoKeysMap = array<value-of<self::SUPPORTED_CAMPO_KEYS>, string> | ||
*/ | ||
final class CampoKeys | ||
{ | ||
public const SCHEMA = [ | ||
'type' => 'object', | ||
'properties' => [ | ||
DegreeProgram::DEGREE => [ | ||
'type' => 'string', | ||
], | ||
DegreeProgram::AREA_OF_STUDY => [ | ||
'type' => 'string', | ||
], | ||
DegreeProgram::LOCATION => [ | ||
'type' => 'string', | ||
], | ||
], | ||
]; | ||
|
||
public const SCHEMA_REQUIRED = [ | ||
'type' => 'object', | ||
'properties' => [ | ||
DegreeProgram::DEGREE => [ | ||
'type' => 'string', | ||
], | ||
DegreeProgram::AREA_OF_STUDY => [ | ||
'type' => 'string', | ||
], | ||
DegreeProgram::LOCATION => [ | ||
'type' => 'string', | ||
], | ||
], | ||
]; | ||
shvlv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public const SUPPORTED_CAMPO_KEYS = [ | ||
DegreeProgram::DEGREE, | ||
DegreeProgram::AREA_OF_STUDY, | ||
DegreeProgram::LOCATION, | ||
]; | ||
|
||
private const HIS_CODE_DELIMITER = '|'; | ||
|
||
private function __construct( | ||
/** | ||
* @var CampoKeysMap $map | ||
*/ | ||
private array $map | ||
) { | ||
} | ||
|
||
public static function empty(): self | ||
{ | ||
return new self([]); | ||
} | ||
|
||
/** | ||
* @param CampoKeysMap $map | ||
*/ | ||
public static function fromArray(array $map): self | ||
{ | ||
return new self($map); | ||
} | ||
|
||
public static function fromHisCode(string $hisCode): self | ||
{ | ||
$parts = explode(self::HIS_CODE_DELIMITER, $hisCode); | ||
$map = [ | ||
DegreeProgram::DEGREE => $parts[0] ?? null, | ||
DegreeProgram::AREA_OF_STUDY => $parts[1] ?? null, | ||
DegreeProgram::LOCATION => $parts[6] ?? null, | ||
]; | ||
|
||
return new self(array_filter($map, fn($value) => !is_null($value))); | ||
} | ||
|
||
/** | ||
* @return CampoKeysMap | ||
*/ | ||
public function asArray(): array | ||
{ | ||
return $this->map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like Campo Keys, which is part of our domain model, as it should be.
What do you think if we remove unrequired getters and setters. I could imagine something like