Encoder::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PSR7SessionEncodeDecode;
6
7
final class Encoder implements EncoderInterface
8
{
9
    /**
10
     * {@inheritDoc}
11
     */
12 4
    public function __invoke(array $sessionData): string
13
    {
14 4
        if (empty($sessionData)) {
15 1
            return '';
16
        }
17
18 3
        $encodedData = '';
19
20 3
        foreach ($sessionData as $key => $value) {
21 3
            $encodedData .= $key . '|' . serialize($value);
22
        }
23
24 3
        return $encodedData;
25
    }
26
}
27