-
Notifications
You must be signed in to change notification settings - Fork 7
/
SoftMocksFactory.php
60 lines (53 loc) · 1.69 KB
/
SoftMocksFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace Mougrim\XdebugProxy\Factory;
use Mougrim\XdebugProxy\Config\Config;
use Mougrim\XdebugProxy\Config\SoftMocksConfig;
use Mougrim\XdebugProxy\RequestPreparer\Error as RequestPreparerError;
use Mougrim\XdebugProxy\RequestPreparer\Exception as RequestPreparerException;
use Mougrim\XdebugProxy\RequestPreparer\RequestPreparer;
use Mougrim\XdebugProxy\RequestPreparer\SoftMocksRequestPreparer;
use Psr\Log\LoggerInterface;
use function array_merge;
/**
* @author Mougrim <rinat@mougrim.ru>
*/
class SoftMocksFactory extends DefaultFactory
{
/**
* @noinspection PhpMissingParentCallCommonInspection
* {@inheritdoc}
*
* @param array<array-key, array> $config
*
* @return SoftMocksConfig
*/
public function createConfig(array $config): Config
{
return new SoftMocksConfig($config);
}
/**
* {@inheritdoc}
*
* @psalm-suppress MoreSpecificImplementedParamType
*
* @param SoftMocksConfig $config
*
* @throws RequestPreparerException
* @throws RequestPreparerError
*
* @return RequestPreparer[]
*/
public function createRequestPreparers(LoggerInterface $logger, Config $config): array
{
$requestPreparers = parent::createRequestPreparers($logger, $config);
return array_merge($requestPreparers, [$this->createSoftMocksRequestPreparer($logger, $config)]);
}
/**
* @throws RequestPreparerError
*/
public function createSoftMocksRequestPreparer(LoggerInterface $logger, SoftMocksConfig $config): SoftMocksRequestPreparer
{
return new SoftMocksRequestPreparer($logger, $config->getSoftMocks()->getInitScript());
}
}