- Add friendsofphp/php-cs-fixer to require-dev - Create .php-cs-fixer.dist.php configured for @PSR12 ruleset - Add php-cs-fixer dry-run step to CI pipeline - Auto-fix existing PSR-12 violations - Document code style tooling in readme.md
17 lines
362 B
PHP
17 lines
362 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Trait;
|
|
|
|
trait StringTrait
|
|
{
|
|
/* cache keys can safely use alphanumeric, "_", and ".", remove the rest */
|
|
private const string KEY_REGEX = '/[^A-Za-z0-9_.]+/';
|
|
|
|
public function makeCacheKey(string $name): string
|
|
{
|
|
return mb_substr(preg_replace(static::KEY_REGEX, '_', $name), 0, 128);
|
|
}
|
|
}
|