Suffix::pack()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace kalanis\UploadPerPartes\Target\Local\DrivingFile\KeyModifiers;
4
5
6
/**
7
 * Class Suffix
8
 * @package kalanis\UploadPerPartes\Target\Local\DrivingFile\KeyModifiers
9
 */
10
class Suffix extends AModifier
11
{
12
    protected string $suffix = '.upload';
13
14 15
    public function pack(string $data): string
15
    {
16 15
        return $data . $this->suffix;
17
    }
18
19 1
    public function unpack(string $data): string
20
    {
21 1
        $len = strlen($this->suffix);
22 1
        $start = substr($data, 0, -1 * $len);
23 1
        $end = substr($data, -1 * $len);
24 1
        return $start . strtr($end, [$this->suffix => '']);
25
    }
26
}
27