Add new report types and language support#5
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for new report types related to civil partnerships and local units, and extends key lookup methods to support language selection for error messages.
Changes:
- Added two new report type constants for legal persons (civil partnership partners and local units list)
- Updated
findByRegon,findByNip, and newfindByKrsmethods to accept a language parameter - Modified error message handling to return localized messages based on language selection
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @throws RegonServiceCallFailedException | ||
| */ | ||
| public function findByRegon(string $regon): array | ||
| public function findByRegon(string $regon, $lng = "pl"): array |
There was a problem hiding this comment.
The parameter $lng lacks type declaration. Add string type hint to ensure type safety and consistency with other parameters.
| * @throws RegonServiceCallFailedException | ||
| */ | ||
| public function findByNip(string $nip): array | ||
| public function findByNip(string $nip, $lng = "pl"): array |
There was a problem hiding this comment.
The parameter $lng lacks type declaration. Add string type hint to ensure type safety and consistency with other parameters.
| * @throws EntityNotFoundException | ||
| * @throws RegonServiceCallFailedException | ||
| */ | ||
| public function findByKrs(string $krs, $lng = "pl"): array |
There was a problem hiding this comment.
The parameter $lng lacks type declaration. Add string type hint to ensure type safety and consistency with other parameters.
| * @throws RegonServiceCallFailedException | ||
| */ | ||
| private function findById($id, $value): array | ||
| private function findById($id, $value, $lng = "pl") |
There was a problem hiding this comment.
Parameters $id, $value, and $lng lack type declarations. Add type hints (string $id, string $value, string $lng) and return type annotation (: array) for type safety.
|
|
||
| // data jako string w formacie YYYY-MM-DD | ||
| public function getCumulativeReport(string $date, string $collectiveReportType) { | ||
| public function getCumulativeReport(string $date, string $collectiveReportType, $lng = "pl"){ |
There was a problem hiding this comment.
The parameter $lng lacks type declaration. Add string type hint to ensure type safety and consistency with other parameters.
| * @throws RegonServiceCallFailedException|EntityNotFoundException | ||
| */ | ||
| public function getReport($regon, $reportType): array | ||
| public function getReport($regon, $reportType, $lng = "pl") |
There was a problem hiding this comment.
Parameters $regon, $reportType, and $lng lack type declarations. Add type hints (string $regon, string $reportType, string $lng) and return type annotation (: array) for type safety.
| if (property_exists($data, 'ErrorCode')) { | ||
| if ($data->ErrorCode == "4") { | ||
| throw new EntityNotFoundException($data->ErrorMessagePL); | ||
| $error = $lng === "pl" ? $data->ErrorMessagePl : $data->ErrorMessageEn; |
There was a problem hiding this comment.
The language parameter accepts any string value without validation. Consider validating that $lng is either 'pl' or 'en' to prevent unexpected behavior when an invalid language code is provided.
|
@copilot, fix php docs and rename $lng to $language |
|
@jedrzejjarocki I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: jedrzejjarocki <46086567+jedrzejjarocki@users.noreply.github.com>
Co-authored-by: jedrzejjarocki <46086567+jedrzejjarocki@users.noreply.github.com>
Co-authored-by: jedrzejjarocki <46086567+jedrzejjarocki@users.noreply.github.com>
Rename $lng to $language and add type hints
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!in_array($reportType, [self::REPORT_TYPE_NATURAL_PERSON_PKD, self::REPORT_TYPE_LEGAL_PERSON_PKD, | ||
| self::REPORT_TYPE_LEGAL_PERSON_CIVIL_PARTNERSHIP_PARTNERS, self::REPORT_TYPE_LEGAL_PERSON_LOCAL_UNITS_LIST | ||
| ])) { |
There was a problem hiding this comment.
This array contains multiple report types that require special handling. Consider extracting this list to a class constant (e.g., REPORT_TYPES_REQUIRING_ARRAY_NORMALIZATION) to improve maintainability and make the purpose clearer.
Add new report types
Update methods: findByRegon, findByNip and findByKrs to support language parameter