This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace PEIP\Plugins; |
||
4 | |||
5 | /* |
||
6 | * To change this template, choose Tools | Templates |
||
7 | * and open the template in the editor. |
||
8 | */ |
||
9 | |||
10 | /** |
||
11 | * Description of BasePlugin. |
||
12 | * |
||
13 | * @author timo |
||
14 | */ |
||
15 | class BasePlugin extends \PEIP\ABS\Context\ContextPlugin implements \PEIP\INF\Context\ContextPlugin |
||
16 | { |
||
17 | protected $builders = [ |
||
18 | 'include' => 'createContext', |
||
19 | 'plugin' => 'createPlugin', |
||
20 | 'channel' => 'createChannel', |
||
21 | 'publish_subscribe_channel' => 'createSubscribableChannel', |
||
22 | 'service_activator' => 'createServiceActivator', |
||
23 | 'gateway' => 'createGateway', |
||
24 | 'splitter' => 'createSplitter', |
||
25 | 'transformer' => 'createTransformer', |
||
26 | 'router' => 'createRouter', |
||
27 | 'aggregator' => 'createAggregator', |
||
28 | 'wiretap' => 'createWiretap', |
||
29 | ]; |
||
30 | |||
31 | /** |
||
32 | * Creates a pollable channel from a configuration object. |
||
33 | * |
||
34 | * @see XMLContext::doCreateChannel |
||
35 | * |
||
36 | * @param object $config configuration object for the pollable channel. |
||
37 | * |
||
38 | * @return \PEIP\INF\Channel\Channel the created pollable channel instance |
||
39 | */ |
||
40 | public function createChannel($config) |
||
41 | { |
||
42 | return $this->doCreateChannel($config, '\PEIP\Channel\PollableChannel'); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Creates a subscribable channel from a configuration object. |
||
47 | * |
||
48 | * @see XMLContext::doCreateChannel |
||
49 | * |
||
50 | * @param object $config configuration object for the subscribable channel. |
||
51 | * |
||
52 | * @return \PEIP\INF\Channel\Channel the created subscribable channel instance |
||
53 | */ |
||
54 | public function createSubscribableChannel($config) |
||
55 | { |
||
56 | return $this->doCreateChannel($config, '\PEIP\Channel\PublishSubscribeChannel'); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Creates and registers arbitrary channel from a configuration object and additional information. |
||
61 | * |
||
62 | * @param object $config configuration object for the channel. |
||
63 | * @param string $defaultChannelClass the channel class to use if none is set in config |
||
64 | * @param $additionalArguments additional arguments for the channel constructor (without first arg = id) |
||
65 | * |
||
66 | * @return \PEIP\INF\Channel\Channel the created channel instance |
||
67 | */ |
||
68 | View Code Duplication | public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = []) |
|
0 ignored issues
–
show
|
|||
69 | { |
||
70 | $id = (string) $config['id']; |
||
71 | if ($id != '') { |
||
72 | array_unshift($additionalArguments, $id); |
||
73 | $channel = $this->buildAndModify($config, $additionalArguments, $defaultChannelClass); |
||
74 | //$this->channelRegistry->register($channel); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
78% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
75 | |||
76 | return $channel; |
||
77 | } |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Creates and registers gateway from a configuration object. |
||
82 | * |
||
83 | * @see XMLContext::initNodeBuilders |
||
84 | * |
||
85 | * @param object $config configuration object for the gateway. |
||
86 | * @param string $defaultClass the class to use if none is set in config. |
||
87 | * |
||
88 | * @return object the gateway instance |
||
89 | */ |
||
90 | View Code Duplication | public function createGateway($config, $defaultClass = false) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
91 | { |
||
92 | $args = [ |
||
93 | $this->getRequestChannel($config), |
||
94 | $this->getReplyChannel($config), |
||
95 | ]; |
||
96 | $defaultClass = $defaultClass ? $defaultClass : '\PEIP\Gateway\SimpleMessagingGateway'; |
||
97 | $gateway = $this->buildAndModify($config, $args, $defaultClass); |
||
98 | $id = (string) $config['id']; |
||
99 | $this->gateways[$id] = $gateway; |
||
0 ignored issues
–
show
The property
gateways does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
100 | |||
101 | return $gateway; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Creates and registers router from a configuration object. |
||
106 | * Adds this context instance as channel-resolver to the router if |
||
107 | * none is set in config. |
||
108 | * |
||
109 | * @see XMLContext::resolveChannelName |
||
110 | * @see XMLContext::initNodeBuilders |
||
111 | * |
||
112 | * @param object $config configuration object for the gateway. |
||
113 | * @param string $defaultClass the class to use if none is set in config. |
||
114 | * |
||
115 | * @return object the router instance |
||
116 | */ |
||
117 | View Code Duplication | public function createRouter($config, $defaultClass = false) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
118 | { |
||
119 | $resolver = $config['channel_resolver'] ? (string) $config['channel_resolver'] : $this->channelRegistry; |
||
0 ignored issues
–
show
The property
channelRegistry does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
120 | |||
121 | return $this->buildAndModify($config, [ |
||
122 | $resolver, |
||
123 | $this->doGetChannel('input', $config), |
||
124 | ], $defaultClass); |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Creates and registers splitter from a configuration object. |
||
129 | * |
||
130 | * @see XMLContext::initNodeBuilders |
||
131 | * @see XMLContext::createReplyMessageHandler |
||
132 | * |
||
133 | * @param object $config configuration object for the splitter. |
||
134 | * |
||
135 | * @return object the splitter instance |
||
136 | */ |
||
137 | public function createSplitter($config) |
||
138 | { |
||
139 | return $this->createReplyMessageHandler($config); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Creates and registers transformer from a configuration object. |
||
144 | * |
||
145 | * @see XMLContext::initNodeBuilders |
||
146 | * @see XMLContext::createReplyMessageHandler |
||
147 | * |
||
148 | * @param object $config configuration object for the transformer. |
||
149 | * |
||
150 | * @return object the transformer instance |
||
151 | */ |
||
152 | public function createTransformer($config) |
||
153 | { |
||
154 | return $this->createReplyMessageHandler($config); |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * Creates aggregator from a configuration object. |
||
159 | * |
||
160 | * @see XMLContext::initNodeBuilders |
||
161 | * @see XMLContext::createReplyMessageHandler |
||
162 | * |
||
163 | * @param object $config configuration object for the aggregator. |
||
164 | * |
||
165 | * @return object the aggregator instance |
||
166 | */ |
||
167 | public function createAggregator($config) |
||
168 | { |
||
169 | return $this->createReplyMessageHandler($config); |
||
170 | } |
||
171 | |||
172 | /** |
||
173 | * Creates wiretap from a configuration object. |
||
174 | * |
||
175 | * @see XMLContext::initNodeBuilders |
||
176 | * @see XMLContext::createReplyMessageHandler |
||
177 | * |
||
178 | * @param object $config configuration object for the wiretap. |
||
179 | * |
||
180 | * @return object the wiretap instance |
||
181 | */ |
||
182 | public function createWiretap($config) |
||
183 | { |
||
184 | return $this->createReplyMessageHandler($config, '\PEIP\Listener\Wiretap'); |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * Creates a reply-message-handler from a configuration object. |
||
189 | * |
||
190 | * @see XMLContext::initNodeBuilders |
||
191 | * |
||
192 | * @param object $config configuration object for the reply-message-handler. |
||
193 | * @param string $defaultClass the class to use if none is set in config. |
||
194 | * |
||
195 | * @return object the reply-message-handler instance |
||
196 | */ |
||
197 | public function createReplyMessageHandler($config, $defaultClass = false) |
||
198 | { |
||
199 | return $this->buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * Creates and registers service-activator from a configuration object. |
||
204 | * |
||
205 | * @see XMLContext::initNodeBuilders |
||
206 | * |
||
207 | * @param object $config configuration object for the service-activator. |
||
208 | * @param string $defaultClass the class to use if none is set in config. |
||
209 | * |
||
210 | * @return object the service-activator instance |
||
211 | */ |
||
212 | View Code Duplication | public function createServiceActivator($config, $defaultClass = false) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
213 | { |
||
214 | $method = (string) $config['method']; |
||
215 | $service = $this->context->getServiceProvider()->provideService((string) $config['ref']); |
||
0 ignored issues
–
show
The method
getServiceProvider() does not exist on PEIP\INF\Context\Context . Did you maybe mean getService() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
216 | if ($method && $service) { |
||
217 | $args = $this->getReplyHandlerArguments($config); |
||
218 | array_unshift($args, [ |
||
219 | $service, |
||
220 | $method, |
||
221 | ]); |
||
222 | $defaultClass = $defaultClass ? $defaultClass : '\PEIP\Service\ServiceActivator'; |
||
223 | |||
224 | return $this->buildAndModify($config, $args, $defaultClass); |
||
225 | } |
||
226 | } |
||
227 | |||
228 | /** |
||
229 | * Utility method to create arguments for a reply-handler constructor from a config-obect. |
||
230 | * |
||
231 | * @param object $config configuration object to create arguments from. |
||
232 | * |
||
233 | * @return mixed build arguments |
||
234 | */ |
||
235 | View Code Duplication | protected function getReplyHandlerArguments($config) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
236 | { |
||
237 | $args = [ |
||
238 | $this->doGetChannel('input', $config), |
||
239 | $this->doGetChannel('output', $config), |
||
240 | ]; |
||
241 | if ($args[0] == null) { |
||
242 | throw new \RuntimeException('Could not receive input channel.'); |
||
243 | } |
||
244 | |||
245 | return $args; |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * Utility method to return a request-channel from a config-obect. |
||
250 | * |
||
251 | * @see XMLContext::doGetChannel |
||
252 | * |
||
253 | * @param object $config configuration object to return request-channel from. |
||
254 | * |
||
255 | * @return \PEIP\INF\Channel\Channel request-channel |
||
256 | */ |
||
257 | protected function getRequestChannel($config) |
||
258 | { |
||
259 | return $this->doGetChannel('request', $config); |
||
260 | } |
||
261 | |||
262 | /** |
||
263 | * Utility method to return a reply-channel from a config-obect. |
||
264 | * |
||
265 | * @see XMLContext::doGetChannel |
||
266 | * |
||
267 | * @param object $config configuration object to return reply-channel from. |
||
268 | * |
||
269 | * @return \PEIP\INF\Channel\Channel reply-channel |
||
270 | */ |
||
271 | protected function getReplyChannel($config) |
||
272 | { |
||
273 | return $this->doGetChannel('reply', $config); |
||
274 | } |
||
275 | |||
276 | /** |
||
277 | * Utility method to return a certainn channel from a config-obect. |
||
278 | * |
||
279 | * @param string the configuration type ofthe channel (e.g.: 'reply', 'request') |
||
280 | * @param object $config configuration object to return channel from. |
||
281 | * |
||
282 | * @return \PEIP\INF\Channel\Channel reply-channel |
||
283 | */ |
||
284 | public function doGetChannel($type, $config) |
||
285 | { |
||
286 | $channelName = isset($config[$type.'_channel']) |
||
287 | ? $config[$type.'_channel'] |
||
288 | : $config['default_'.$type.'_channel']; |
||
289 | |||
290 | return $this->context->getServiceProvider()->provideService(trim((string) $channelName)); |
||
0 ignored issues
–
show
The method
getServiceProvider() does not exist on PEIP\INF\Context\Context . Did you maybe mean getService() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
291 | } |
||
292 | } |
||
293 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.