@@ 40-62 (lines=23) @@ | ||
37 | return $this->strategies; |
|
38 | } |
|
39 | ||
40 | public function get($object, string $key): ExtractionStrategyInterface |
|
41 | { |
|
42 | $strategy = $this->getCachedStrategy(get_class($object), $key); |
|
43 | if (null !== $strategy) { |
|
44 | return $strategy; |
|
45 | } |
|
46 | ||
47 | foreach ($this->all() as $strategy) { |
|
48 | if ($strategy->supports($object, $key)) { |
|
49 | ||
50 | $this->setCachedStrategy(get_class($object), $key, $strategy); |
|
51 | ||
52 | return $strategy; |
|
53 | } |
|
54 | } |
|
55 | ||
56 | throw new LogicException( |
|
57 | sprintf( |
|
58 | 'Property "%s" cannot be extracted', |
|
59 | $key |
|
60 | ) |
|
61 | ); |
|
62 | } |
|
63 | ||
64 | } |
|
65 |
@@ 37-59 (lines=23) @@ | ||
34 | return $this->strategies; |
|
35 | } |
|
36 | ||
37 | public function get($object, string $key, $value): InjectionStrategyInterface |
|
38 | { |
|
39 | $strategy = $this->getCachedStrategy(get_class($object), $key); |
|
40 | if (null !== $strategy) { |
|
41 | return $strategy; |
|
42 | } |
|
43 | ||
44 | foreach ($this->all() as $strategy) { |
|
45 | if ($strategy->supports($object, $key, $value)) { |
|
46 | ||
47 | $this->setCachedStrategy(get_class($object), $key, $strategy); |
|
48 | ||
49 | return $strategy; |
|
50 | } |
|
51 | } |
|
52 | ||
53 | throw new LogicException( |
|
54 | sprintf( |
|
55 | 'Property "%s" cannot be injected', |
|
56 | $key |
|
57 | ) |
|
58 | ); |
|
59 | } |
|
60 | } |
|
61 |