Skip to content

Add new report types and language support#5

Merged
jedrzejjarocki merged 8 commits intomainfrom
add-new-report-types
Jan 21, 2026
Merged

Add new report types and language support#5
jedrzejjarocki merged 8 commits intomainfrom
add-new-report-types

Conversation

@MaciekR-Job
Copy link
Copy Markdown
Contributor

Add new report types
Update methods: findByRegon, findByNip and findByKrs to support language parameter

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 new findByKrs methods 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.

Comment thread src/RegonClient.php Outdated
* @throws RegonServiceCallFailedException
*/
public function findByRegon(string $regon): array
public function findByRegon(string $regon, $lng = "pl"): array
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter $lng lacks type declaration. Add string type hint to ensure type safety and consistency with other parameters.

Copilot uses AI. Check for mistakes.
Comment thread src/RegonClient.php Outdated
* @throws RegonServiceCallFailedException
*/
public function findByNip(string $nip): array
public function findByNip(string $nip, $lng = "pl"): array
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter $lng lacks type declaration. Add string type hint to ensure type safety and consistency with other parameters.

Copilot uses AI. Check for mistakes.
Comment thread src/RegonClient.php Outdated
* @throws EntityNotFoundException
* @throws RegonServiceCallFailedException
*/
public function findByKrs(string $krs, $lng = "pl"): array
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter $lng lacks type declaration. Add string type hint to ensure type safety and consistency with other parameters.

Copilot uses AI. Check for mistakes.
Comment thread src/RegonClient.php Outdated
* @throws RegonServiceCallFailedException
*/
private function findById($id, $value): array
private function findById($id, $value, $lng = "pl")
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread src/RegonClient.php Outdated

// data jako string w formacie YYYY-MM-DD
public function getCumulativeReport(string $date, string $collectiveReportType) {
public function getCumulativeReport(string $date, string $collectiveReportType, $lng = "pl"){
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter $lng lacks type declaration. Add string type hint to ensure type safety and consistency with other parameters.

Copilot uses AI. Check for mistakes.
Comment thread src/RegonClient.php Outdated
* @throws RegonServiceCallFailedException|EntityNotFoundException
*/
public function getReport($regon, $reportType): array
public function getReport($regon, $reportType, $lng = "pl")
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread src/RegonClient.php Outdated
if (property_exists($data, 'ErrorCode')) {
if ($data->ErrorCode == "4") {
throw new EntityNotFoundException($data->ErrorMessagePL);
$error = $lng === "pl" ? $data->ErrorMessagePl : $data->ErrorMessageEn;
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 uses AI. Check for mistakes.
@jedrzejjarocki
Copy link
Copy Markdown
Contributor

@copilot, fix php docs and rename $lng to $language

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 19, 2026

@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.

Copilot AI and others added 4 commits January 19, 2026 17:45
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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/RegonClient.php
Comment thread src/RegonClient.php
Comment thread src/RegonClient.php
Comment on lines +239 to +241
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
])) {
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread src/RegonClient.php
@jedrzejjarocki jedrzejjarocki merged commit 68bdba5 into main Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants