Skip to content

Commit

Permalink
Update docblock for pregReplace.
Browse files Browse the repository at this point in the history
  • Loading branch information
david_smith committed Nov 7, 2024
1 parent a613054 commit c5873e2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/DataModelHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ public static function mapOf(mixed $value, array $context, ?ReflectionAttribute
return $mapper($value, $args[0]['level'] ?? 1);
}

/**
* Perform a regular expression search and replace.
*
* NOTE: If property allows null, null will be returned, else an empty string.
*
* ```
* #[Describe([
* 'cast' => [self::class, 'pregReplace'],
* 'pattern' => '/s/', // any regular expression
* 'replacement' => '' // default
* ])]
* ```
*/
public static function pregReplace(mixed $value, array $context, ?ReflectionAttribute $Attribute, ReflectionProperty $Property): array|string|null
{
if (!$value) {
Expand Down

0 comments on commit c5873e2

Please sign in to comment.