Completed
Push — develop ( 88b170...792ec8 )
by Baptiste
02:04
created

Psr7TranslatorFactory::make()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Rest\ClientBundle;
5
6
use Innmind\Http\{
7
    Translator\Response\Psr7Translator,
8
    Factory\HeaderFactoryInterface,
9
    Factory\Header\DefaultFactory
10
};
11
use Innmind\Immutable\Map;
12
13
final class Psr7TranslatorFactory
14
{
15 1
    public function make(array $classes): Psr7Translator
16
    {
17 1
        $factories = new Map('string', HeaderFactoryInterface::class);
18
19 1
        foreach ($classes as $class => $header) {
20 1
            $factories = $factories->put(
21
                $header,
22 1
                new $class
23
            );
24
        }
25
26 1
        return new Psr7Translator(
27 1
            new DefaultFactory($factories)
28
        );
29
    }
30
}
31