Lines 66.66% 2 / 3
Methods 66.66% 2 / 3
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __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
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}