PluginProbe
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More / 2.11.0
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More v2.11.0
2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.7 2.6.8 2.6.5 2.6.4 2.6.3 2.6.2 2.6.0 2.5.5 2.5.4 2.5.3 2.5.2 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1 1.1.1 1.1.2 1.2.0 All 37 releases
reviews-feed / vendor / php-di / invoker / src / ParameterResolver / AssociativeArrayResolver.php
AssociativeArrayResolver.php
32 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace SmashBalloon\Reviews\Vendor\Invoker\ParameterResolver;
5
6 use ReflectionFunctionAbstract;
7 /**
8 * Tries to map an associative array (string-indexed) to the parameter names.
9 *
10 * E.g. `->call($callable, ['foo' => 'bar'])` will inject the string `'bar'`
11 * in the parameter named `$foo`.
12 *
13 * Parameters that are not indexed by a string are ignored.
14 */
15 class AssociativeArrayResolver implements ParameterResolver
16 {
17 public function getParameters(ReflectionFunctionAbstract $reflection, array $providedParameters, array $resolvedParameters): array
18 {
19 $parameters = $reflection->getParameters();
20 // Skip parameters already resolved
21 if (!empty($resolvedParameters)) {
22 $parameters = array_diff_key($parameters, $resolvedParameters);
23 }
24 foreach ($parameters as $index => $parameter) {
25 if (array_key_exists($parameter->name, $providedParameters)) {
26 $resolvedParameters[$index] = $providedParameters[$parameter->name];
27 }
28 }
29 return $resolvedParameters;
30 }
31 }
32