Skip to content

Commit 4efee0c

Browse files
committed
Added Porter v5 UML class diagram.
1 parent a38cc2b commit 4efee0c

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Porter's API
118118
Porter's asynchronous API mirrors the synchronous one with similar method names but different signatures.
119119

120120
* `importAsync(AsyncImportSpecification): AsyncPorterRecords|CountableAsyncPorterRecords` – Imports one or more records asynchronously from the resource contained in the specified asynchronous import specification.
121-
* `importOneAsync(AsyncImportSpecification): Promise` – Imports one record from the resource contained in the specified asynchronous import specification.
121+
* `importOneAsync(AsyncImportSpecification): Promise<array>` &ndash; Imports one record from the resource contained in the specified asynchronous import specification.
122122

123123
Overview
124124
--------
@@ -250,10 +250,12 @@ Durability only applies when connectors throw a recoverable exception type deriv
250250
Caching
251251
-------
252252

253-
Any connector can be wrapped in a `CachingConnector` to provide [PSR-6][] caching facilities to the base connector. Porter ships with one cache implementation, `MemoryCache`, which caches fetched data in memory, but this can be substituted for any other PSR-6 cache implementation. The `CachingConnector` caches raw responses for each unique [cache key](#cache-keys).
253+
Any connector can be wrapped in a `CachingConnector` to provide [PSR-6][] caching facilities to the base connector. Porter ships with one cache implementation, `MemoryCache`, which caches fetched data in memory, but this can be substituted for any other PSR-6 cache implementation. The `CachingConnector` caches raw responses for each unique request, where uniqueness is determined by `DataSource::computeHash`.
254254

255255
Remember that whilst using a `CachingConnector` enables caching, caching must also be enabled on a per-import basis by calling `ImportSpecification::enableCache()`.
256256

257+
Note that Caching is not yet supported for asynchronous imports.
258+
257259
### Example
258260

259261
The follow example enables connector caching.
@@ -283,7 +285,7 @@ The rest of this readme is for those wishing to go deeper. Continue when you're
283285
Architecture
284286
------------
285287

286-
The following UML class diagram shows a partial architectural overview illustrating Porter's main components and how they are related. [[enlarge][Class diagram]]
288+
The following UML class diagram shows a partial architectural overview illustrating Porter's main components and how they are related. Asynchronous implementation details are mostly omitted since they mirror the synchronous system. [[enlarge][Class diagram]]
287289

288290
[![Class diagram][]][Class diagram]
289291

@@ -330,7 +332,7 @@ Resources fetch data using the supplied connector and format it as a collection
330332

331333
```php
332334
public function getProviderClassName(): string;
333-
public function fetch(ImportConnector $connector): Iterator;
335+
public function fetch(ImportConnector $connector): \Iterator;
334336
```
335337

336338
A resource supplies the class name of the provider it expects a connector from when `getProviderClassName()` is called.
@@ -348,7 +350,7 @@ Resources must implement the `ProviderResource` interface. `getProviderClassName
348350
In this contrived example that uses dummy data and ignores the connector, suppose we want to return the numeric series one to three: the following implementation would be invalid because it returns an iterator of integer values instead of an iterator of array values.
349351

350352
```php
351-
public function fetch(ImportConnector $connector)
353+
public function fetch(ImportConnector $connector): \Iterator
352354
{
353355
return new ArrayIterator(range(1, 3)); // Invalid return type.
354356
}
@@ -357,7 +359,7 @@ public function fetch(ImportConnector $connector)
357359
Either of the following `fetch()` implementations would be valid.
358360

359361
```php
360-
public function fetch(ImportConnector $connector)
362+
public function fetch(ImportConnector $connector): \Iterator
361363
{
362364
foreach (range(1, 3) as $number) {
363365
yield [$number];
@@ -368,7 +370,7 @@ public function fetch(ImportConnector $connector)
368370
Since the total number of records is known, the iterator can be wrapped in `CountableProviderRecords` to enrich the caller with this information.
369371

370372
```php
371-
public function fetch(ImportConnector $connector)
373+
public function fetch(ImportConnector $connector): \Iterator
372374
{
373375
$series = function ($limit) {
374376
foreach (range(1, $limit) as $number) {
@@ -515,7 +517,7 @@ Porter is published under the open source GNU Lesser General Public License v3.0
515517
[Porter icon]: https://avatars3.githubusercontent.com/u/16755913?v=3&s=35 "Porter providers"
516518
[Porter transformers icon]: https://avatars2.githubusercontent.com/u/24607042?v=3&s=35 "Porter transformers"
517519
[Porter connectors icon]: https://avatars3.githubusercontent.com/u/25672142?v=3&s=35 "Porter connectors"
518-
[Class diagram]: https://github.com/ScriptFUSION/Porter/blob/master/docs/images/diagrams/Porter%20UML%20class%20diagram%204.0.png?raw=true
520+
[Class diagram]: https://github.com/ScriptFUSION/Porter/blob/master/docs/images/diagrams/Porter%20UML%20class%20diagram%205.0.png?raw=true
519521
[Data flow diagram]: https://github.com/ScriptFUSION/Porter/blob/master/docs/images/diagrams/Porter%20data%20flow%20diagram%205.0.png?raw=true
520522
[ECB]: https://github.com/Provider/European-Central-Bank
521523
[CurrencyRecords]: https://github.com/Provider/European-Central-Bank/blob/master/src/Records/CurrencyRecords.php
165 KB
Loading

src/Cache/MemoryCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MemoryCache extends \ArrayObject implements CacheItemPoolInterface
1919
public function getItem($key)
2020
{
2121
return \Closure::bind(
22-
function () use ($key): CacheItem {
22+
function () use ($key): self {
2323
return new self($key, $this->hasItem($key) ? $this[$key] : null, $this->hasItem($key));
2424
},
2525
$this,

src/Porter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private function fetch(ImportSpecification $specification): PorterRecords
143143
* @throws IncompatibleResourceException Resource emits a single record and must be imported with
144144
* importOneAsync() instead.
145145
*/
146-
public function importAsync(AsyncImportSpecification $specification): AsyncRecordCollection
146+
public function importAsync(AsyncImportSpecification $specification): AsyncPorterRecords
147147
{
148148
if ($specification->getAsyncResource() instanceof SingleRecordResource) {
149149
throw IncompatibleResourceException::createMustNotImplementInterfaceAsync();
@@ -183,7 +183,7 @@ public function importOneAsync(AsyncImportSpecification $specification): Promise
183183
});
184184
}
185185

186-
private function fetchAsync(AsyncImportSpecification $specification): AsyncRecordCollection
186+
private function fetchAsync(AsyncImportSpecification $specification): AsyncPorterRecords
187187
{
188188
$specification = clone $specification;
189189
$resource = $specification->getAsyncResource();

0 commit comments

Comments
 (0)