VcrRecordFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 15
ccs 0
cts 7
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createPlugin() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\HTTPlugModule\PluginFactory;
6
7
use Http\Client\Common\Plugin;
8
use Http\Client\Plugin\Vcr\RecordPlugin;
9
use LogicException;
10
11
class VcrRecordFactory extends AbstractVcrFactory
12
{
13
    /**
14
     * @param array<string, mixed> $config
15
     */
16
    public function createPlugin(array $config = []): Plugin
17
    {
18
        if (! class_exists(RecordPlugin::class)) {
19
            throw new LogicException('To use the vcr record plugin you need to install the "php-http/vcr-plugin" package.');
20
        }
21
22
        $recorder = $this->getRecorder($config['recorder'] ?? 'filesystem', $config);
23
        $namingStrategy = $this->getNamingStrategy($config['naming_strategy'] ?? 'default', $config);
24
25
        return new RecordPlugin($namingStrategy, $recorder);
26
    }
27
}
28