1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Oliverde8\Component\PhpEtl\Builder\Factories\Transformer; |
6
|
|
|
|
7
|
|
|
use Oliverde8\Component\PhpEtl\Builder\Factories\AbstractFactory; |
8
|
|
|
use Oliverde8\Component\PhpEtl\ChainOperation\ChainOperationInterface; |
9
|
|
|
use Oliverde8\Component\PhpEtl\ChainOperation\Transformer\SimpleHttpOperation; |
10
|
|
|
use Symfony\Component\HttpClient\HttpClient; |
|
|
|
|
11
|
|
|
use Symfony\Component\Validator\Constraint; |
12
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
13
|
|
|
|
14
|
|
|
class SimpleHttpOperationFactory extends AbstractFactory |
15
|
|
|
{ |
16
|
|
|
protected function build(string $operation, array $options): ChainOperationInterface |
17
|
|
|
{ |
18
|
|
|
if (!class_exists(HttpClient::class)) { |
19
|
|
|
throw new \LogicException("You can not used SimpleHttpOperation as symfony/http-client is not installed"); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
$httpClient = HttpClient::create($options['options']); |
23
|
|
|
|
24
|
|
|
return new SimpleHttpOperation( |
25
|
|
|
$httpClient, |
26
|
|
|
$options['method'], |
27
|
|
|
$options['url'], |
28
|
|
|
$options['response_is_json'] ?? false, |
29
|
|
|
$options['option_key'] ?? null, |
30
|
|
|
$options['response_key'] ?? null, |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function configureValidator(): Constraint |
35
|
|
|
{ |
36
|
|
|
return new Assert\Collection([ |
37
|
|
|
'method' => [ |
38
|
|
|
new Assert\Choice(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD']), |
39
|
|
|
new Assert\NotBlank(), |
40
|
|
|
], |
41
|
|
|
'url' => [ |
42
|
|
|
new Assert\Type(["type" => "string"]), |
43
|
|
|
new Assert\NotBlank(), |
44
|
|
|
], |
45
|
|
|
'response_is_json' => [ |
46
|
|
|
new Assert\Type(["type" => "boolean"]), |
47
|
|
|
], |
48
|
|
|
'option_key' => [ |
49
|
|
|
new Assert\Type(["type" => "string"]), |
50
|
|
|
], |
51
|
|
|
'response_key' => [ |
52
|
|
|
new Assert\Type(["type" => "string"]), |
53
|
|
|
], |
54
|
|
|
'options' => [ |
55
|
|
|
new Assert\Type(["type" => "array"]), |
56
|
|
|
], |
57
|
|
|
]); |
58
|
|
|
} |
59
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths