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

CanonicalizeBodySimple::name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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
}