Skip to content

Conversation

stunnerparas
Copy link
Contributor

[Grid][Transformer] Anonymizer (Mask, Initial, Partial, Hide)

@stunnerparas stunnerparas added this to the next milestone Oct 7, 2025
@stunnerparas stunnerparas self-assigned this Oct 7, 2025
Copy link

@Copilot 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 introduces an Anonymizer transformer for the grid system that provides data anonymization capabilities for protecting sensitive information in grid views. It implements four different anonymization strategies: masking, initials conversion, partial reveal, and complete hiding.

  • Adds a new Anonymizer transformer class with four anonymization rules
  • Registers the transformer in the service container
  • Updates documentation with usage examples and configuration options

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/Grid/Column/Transformer/Anonymizer.php Implements the core anonymization logic with mask, initials, partial, and hide strategies
doc/03_Grid.md Documents the transformer's configuration options and provides usage examples
config/grid.yaml Registers the new Anonymizer transformer as a tagged service

$initials = [];

foreach ($segments as $segment) {
$parts = preg_split('/\s+/', trim($segment));
Copy link
Preview

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Missing import for preg_split function. Add use function preg_split; to the function imports at the top of the file to follow the established pattern.

Copilot uses AI. Check for mistakes.

Comment on lines 124 to 127
$initials[] = implode('.', array_map(
static fn (string $part): string => mb_strtoupper(mb_substr($part, 0, 1)),
array_filter($parts)
)) . '.';
Copy link
Preview

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Missing imports for implode, array_map, array_filter, mb_strtoupper, and mb_substr functions. Add these to the function imports at the top of the file to follow the established pattern.

Copilot uses AI. Check for mistakes.

)) . '.';
}

return implode(', ', $initials);
Copy link
Preview

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Missing import for implode function (if not already added from previous comment). Add use function implode; to the function imports.

Copilot uses AI. Check for mistakes.

$minMaskLength = 3;
$minDomainMaskLength = 5;

if (!str_contains($value, '@')) {
Copy link
Preview

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Missing import for str_contains function. Add use function str_contains; to the function imports at the top of the file to follow the established pattern.

Copilot uses AI. Check for mistakes.

}

return implode(', ', $initials);

Copy link
Preview

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Remove the unnecessary empty line before the closing brace to improve code consistency.

Suggested change

Copilot uses AI. Check for mistakes.

Copy link

sonarqubecloud bot commented Oct 7, 2025

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
40.3% Duplication on New Code

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant