|
9 | 9 | use ScriptFUSION\Porter\Collection\RecordCollection; |
10 | 10 | use ScriptFUSION\Porter\Connector\ConnectionContext; |
11 | 11 | use ScriptFUSION\Porter\Connector\ConnectionContextFactory; |
| 12 | +use ScriptFUSION\Porter\Connector\ConnectorOptions; |
12 | 13 | use ScriptFUSION\Porter\Connector\ImportConnector; |
13 | 14 | use ScriptFUSION\Porter\Provider\ForeignResourceException; |
14 | 15 | use ScriptFUSION\Porter\Provider\ObjectNotCreatedException; |
15 | 16 | use ScriptFUSION\Porter\Provider\Provider; |
16 | 17 | use ScriptFUSION\Porter\Provider\ProviderFactory; |
17 | | -use ScriptFUSION\Porter\Provider\ProviderOptions; |
18 | 18 | use ScriptFUSION\Porter\Provider\Resource\ProviderResource; |
19 | 19 | use ScriptFUSION\Porter\Specification\ImportSpecification; |
20 | 20 | use ScriptFUSION\Porter\Transform\Transformer; |
@@ -109,10 +109,17 @@ private function fetch(ProviderResource $resource, $providerName, ConnectionCont |
109 | 109 | )); |
110 | 110 | } |
111 | 111 |
|
112 | | - $records = $resource->fetch( |
113 | | - new ImportConnector($provider->getConnector(), $context), |
114 | | - $provider instanceof ProviderOptions ? clone $provider->getOptions() : null |
115 | | - ); |
| 112 | + $connector = $provider->getConnector(); |
| 113 | + |
| 114 | + /* __clone method cannot be specified in interface due to Mockery limitation. |
| 115 | + See https://github.com/mockery/mockery/issues/669 */ |
| 116 | + if ($connector instanceof ConnectorOptions && !method_exists($connector, '__clone')) { |
| 117 | + throw new \LogicException( |
| 118 | + 'Connector with options must implement __clone() method to deep clone options.' |
| 119 | + ); |
| 120 | + } |
| 121 | + |
| 122 | + $records = $resource->fetch(new ImportConnector(clone $connector, $context)); |
116 | 123 |
|
117 | 124 | if (!$records instanceof \Iterator) { |
118 | 125 | throw new ImportException(get_class($resource) . '::fetch() did not return an Iterator.'); |
|
0 commit comments