Completed
Pull Request — master (#18)
by Frederik
03:05
created

CanonicalizeBodySimple::canonicalize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Dkim;
5
6
use Genkgo\Mail\StreamInterface;
7
8
final class CanonicalizeBodySimple implements CanonicalizeBodyInterface
9
{
10
    /**
11
     * @param StreamInterface $body
12
     * @return string
13
     */
14
    public function canonicalize(StreamInterface $body): string
15
    {
16
        $string = (string)$body;
17
        if (substr($string, -2, 2) === "\r\n") {
18
            return rtrim($string, "\r\n") . "\r\n";
19
        }
20
21
        return $string;
22
    }
23
24
    /**
25
     * @return string
26
     */
27
    public static function name(): string
28
    {
29
        return 'simple';
30
    }
31
}