Lines 66.66% 2 / 3
Functions and Methods 66.66% 2 / 3
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
SecretName 66.66% 2 / 3 66.66% 2 / 3 3.33 0.00% 0 / 1
 __construct 0.00% 0 / 1 0.00% 0 / 1 2
 looksSecret 100.00% 1 / 1 100.00% 1 / 1 1
 looksLikeCredentialParameter 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Support\Secret;
6
7/** @internal */
8final class SecretName
9{
10    private const string SECRET = 'token|secret|password|passwd|(?<![a-z])pass(?![a-z])|api_?key';
11
12    private const string CREDENTIAL_PARAMETER_EXTRAS = 'auth|signature|sig';
13
14    private function __construct() {}
15
16    public static function looksSecret(string $name): bool
17    {
18        return preg_match('/' . self::SECRET . '/i', $name) === 1;
19    }
20
21    public static function looksLikeCredentialParameter(string $name): bool
22    {
23        return preg_match('/' . self::SECRET . '|' . self::CREDENTIAL_PARAMETER_EXTRAS . '/i', $name) === 1;
24    }
25}