Completed
Push — master ( 5429ef...771e5d )
by Jeff
04:44 queued 02:38
created

FormatterService   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTXTRecord() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * This file is part of the mailserver-admin package.
6
 * (c) Jeffrey Boehm <https://github.com/jeboehm/mailserver-admin>
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace App\Service\DKIM;
12
13
class FormatterService
14
{
15
    public function getTXTRecord(string $publicKey, string $algorithm): string
16
    {
17
        $publicKey = preg_replace('/^-+.*?-+$/m', '', $publicKey);
18
        $publicKey = str_replace(["\r", "\n"], '', $publicKey);
19
20
        return sprintf('v=DKIM1\; h=%s\; t=s\; p=%s', $algorithm, $publicKey);
21
    }
22
}
23