@@ 41-69 (lines=29) @@ | ||
38 | * @param string|null $httpClient |
|
39 | * @param ContainerBuilder $container |
|
40 | */ |
|
41 | private function configureHttpClient($httpClient, ContainerBuilder $container) |
|
42 | { |
|
43 | $httpClient = $httpClient ?: $this->autoDiscoverHttpClient(); |
|
44 | ||
45 | if (!class_exists($httpClient)) { |
|
46 | // is a service |
|
47 | $container->setAlias('zenstruck_cache.http_client', $httpClient); |
|
48 | ||
49 | return; |
|
50 | } |
|
51 | ||
52 | $r = new \ReflectionClass($httpClient); |
|
53 | ||
54 | if (!$r->implementsInterface('Http\Client\HttpClient')) { |
|
55 | throw new InvalidConfigurationException('HttpClient class must implement "Http\Client\HttpClient".'); |
|
56 | } |
|
57 | ||
58 | if ($r->isAbstract()) { |
|
59 | throw new InvalidConfigurationException('HttpClient class must not be abstract.'); |
|
60 | } |
|
61 | ||
62 | if (null !== $r->getConstructor() && 0 !== $r->getConstructor()->getNumberOfRequiredParameters()) { |
|
63 | throw new InvalidConfigurationException('HttpClient class must not have required constructor arguments.'); |
|
64 | } |
|
65 | ||
66 | $httpClient = new Definition($httpClient); |
|
67 | $httpClient->setPublic(false); |
|
68 | $container->setDefinition('zenstruck_cache.http_client', $httpClient); |
|
69 | } |
|
70 | ||
71 | /** |
|
72 | * @param string|null $messageFactory |
|
@@ 75-103 (lines=29) @@ | ||
72 | * @param string|null $messageFactory |
|
73 | * @param ContainerBuilder $container |
|
74 | */ |
|
75 | private function configureMessageFactory($messageFactory, ContainerBuilder $container) |
|
76 | { |
|
77 | $messageFactory = $messageFactory ?: $this->autoDiscoverMessageFactory(); |
|
78 | ||
79 | if (!class_exists($messageFactory)) { |
|
80 | // is a service |
|
81 | $container->setAlias('zenstruck_cache.message_factory', $messageFactory); |
|
82 | ||
83 | return; |
|
84 | } |
|
85 | ||
86 | $r = new \ReflectionClass($messageFactory); |
|
87 | ||
88 | if (!$r->implementsInterface('Http\Message\MessageFactory')) { |
|
89 | throw new InvalidConfigurationException('MessageFactory class must implement "Http\Message\MessageFactory".'); |
|
90 | } |
|
91 | ||
92 | if ($r->isAbstract()) { |
|
93 | throw new InvalidConfigurationException('MessageFactory class must not be abstract.'); |
|
94 | } |
|
95 | ||
96 | if (null !== $r->getConstructor() && 0 !== $r->getConstructor()->getNumberOfRequiredParameters()) { |
|
97 | throw new InvalidConfigurationException('MessageFactory class must not have required constructor arguments.'); |
|
98 | } |
|
99 | ||
100 | $messageFactory = new Definition($messageFactory); |
|
101 | $messageFactory->setPublic(false); |
|
102 | $container->setDefinition('zenstruck_cache.message_factory', $messageFactory); |
|
103 | } |
|
104 | ||
105 | /** |
|
106 | * @return string |