Skip to content

Commit 42147d4

Browse files
committed
Added resource type parameter to Provider::getConnector.
1 parent 61f6432 commit 42147d4

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

src/Connector/CachingConnector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function __construct(
3939
}
4040

4141
/**
42+
* @param ConnectionContext $context
4243
* @param string $source
4344
* @param EncapsulatedOptions|null $options
4445
*

src/Porter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function fetch(ProviderResource $resource, $providerName, ConnectionCont
110110
}
111111

112112
$records = $resource->fetch(
113-
new ImportConnector($provider->getConnector(), $context),
113+
new ImportConnector($provider->getConnector(get_class($resource)), $context),
114114
$provider instanceof ProviderOptions ? clone $provider->getOptions() : null
115115
);
116116

src/Provider/Provider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
use ScriptFUSION\Porter\Connector\Connector;
55

66
/**
7-
* Provides a method for accessing a connector.
7+
* Provides a method for getting a connector.
88
*/
99
interface Provider
1010
{
1111
/**
12-
* Gets a connector for accessing resource data.
12+
* Gets a connector for fetching resource data.
13+
*
14+
* @param string $resourceType The resource type from which data will be fetched.
1315
*
1416
* @return Connector
1517
*/
16-
public function getConnector();
18+
public function getConnector($resourceType);
1719
}

src/Provider/StaticDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function __construct()
1212
$this->connector = new NullConnector;
1313
}
1414

15-
public function getConnector()
15+
public function getConnector($resourceType)
1616
{
1717
return $this->connector;
1818
}

test/Integration/Porter/PorterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function setUp()
6868
$this->porter = new Porter($this->container = \Mockery::spy(ContainerInterface::class));
6969

7070
$this->registerProvider($this->provider = MockFactory::mockProvider());
71-
$this->connector = $this->provider->getConnector();
71+
$this->connector = $this->provider->getConnector('');
7272
$this->resource = MockFactory::mockResource($this->provider);
7373
$this->specification = new ImportSpecification($this->resource);
7474
}

test/MockFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ public static function mockProvider()
2020
{
2121
return \Mockery::namedMock(uniqid(Provider::class, false), Provider::class)
2222
->shouldReceive('getConnector')
23+
->with(\Mockery::type('string'))
2324
->andReturn(
2425
\Mockery::mock(Connector::class)
2526
->shouldReceive('fetch')
2627
->andReturn('foo')
27-
->getMock()
2828
->byDefault()
29+
->getMock()
2930
)
3031
->getMock()
3132
;

0 commit comments

Comments
 (0)