diff --git a/src/Collection/RecordCollection.php b/src/Collection/RecordCollection.php index 09d6d54..5a5eb07 100644 --- a/src/Collection/RecordCollection.php +++ b/src/Collection/RecordCollection.php @@ -10,7 +10,7 @@ abstract class RecordCollection implements \Iterator private $previousCollection; - public function __construct(\Iterator $records, RecordCollection $previousCollection = null) + public function __construct(\Iterator $records, self $previousCollection = null) { $this->records = $records; $this->previousCollection = $previousCollection; diff --git a/src/Connector/CachingConnector.php b/src/Connector/CachingConnector.php index e163d11..6e15590 100644 --- a/src/Connector/CachingConnector.php +++ b/src/Connector/CachingConnector.php @@ -39,6 +39,7 @@ public function __construct( } /** + * @param ConnectionContext $context * @param string $source * @param EncapsulatedOptions|null $options * diff --git a/src/Porter.php b/src/Porter.php index d6589c0..853b127 100644 --- a/src/Porter.php +++ b/src/Porter.php @@ -110,7 +110,7 @@ private function fetch(ProviderResource $resource, $providerName, ConnectionCont } $records = $resource->fetch( - new ImportConnector($provider->getConnector(), $context), + new ImportConnector($provider->getConnector(get_class($resource)), $context), $provider instanceof ProviderOptions ? clone $provider->getOptions() : null ); diff --git a/src/Provider/Provider.php b/src/Provider/Provider.php index 067d811..e708c56 100644 --- a/src/Provider/Provider.php +++ b/src/Provider/Provider.php @@ -4,14 +4,16 @@ use ScriptFUSION\Porter\Connector\Connector; /** - * Provides a method for accessing a connector. + * Provides a method for getting a connector. */ interface Provider { /** - * Gets a connector for accessing resource data. + * Gets a connector for fetching resource data. + * + * @param string $resourceType The resource type from which data will be fetched. * * @return Connector */ - public function getConnector(); + public function getConnector($resourceType); } diff --git a/src/Provider/StaticDataProvider.php b/src/Provider/StaticDataProvider.php index e857b76..418ab4b 100644 --- a/src/Provider/StaticDataProvider.php +++ b/src/Provider/StaticDataProvider.php @@ -12,7 +12,7 @@ public function __construct() $this->connector = new NullConnector; } - public function getConnector() + public function getConnector($resourceType) { return $this->connector; } diff --git a/test/Integration/Porter/PorterTest.php b/test/Integration/Porter/PorterTest.php index 5d9ad3e..2a7b395 100644 --- a/test/Integration/Porter/PorterTest.php +++ b/test/Integration/Porter/PorterTest.php @@ -68,7 +68,7 @@ protected function setUp() $this->porter = new Porter($this->container = \Mockery::spy(ContainerInterface::class)); $this->registerProvider($this->provider = MockFactory::mockProvider()); - $this->connector = $this->provider->getConnector(); + $this->connector = $this->provider->getConnector(''); $this->resource = MockFactory::mockResource($this->provider); $this->specification = new ImportSpecification($this->resource); } diff --git a/test/MockFactory.php b/test/MockFactory.php index 1400bf6..7e1fa06 100644 --- a/test/MockFactory.php +++ b/test/MockFactory.php @@ -20,12 +20,13 @@ public static function mockProvider() { return \Mockery::namedMock(uniqid(Provider::class, false), Provider::class) ->shouldReceive('getConnector') + ->with(\Mockery::type('string')) ->andReturn( \Mockery::mock(Connector::class) ->shouldReceive('fetch') ->andReturn('foo') - ->getMock() ->byDefault() + ->getMock() ) ->getMock() ;