Skip to content

Commit 0b20546

Browse files
committed
Changed Porter class to final.
Minor updates to Readme.
1 parent 90a08b0 commit 0b20546

File tree

3 files changed

+37
-45
lines changed

3 files changed

+37
-45
lines changed

README.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Porter <img src="https://github.com/ScriptFUSION/Porter/blob/master/docs/images/porter%20222x.png?raw=true" align="right">
32
======
43

@@ -12,7 +11,7 @@ Porter <img src="https://github.com/ScriptFUSION/Porter/blob/master/docs/images/
1211

1312
Porter is the all-purpose PHP data importer. She fetches data from anywhere and serves it as a single record or an iterable [record collection](#record-collections), encouraging processing one record at a time instead of loading full data sets into memory at once. Her [durability](#durability) feature provides automatic, transparent recovery from intermittent network connectivity errors by default.
1413

15-
Porter's [interface trichotomy](#overview) of [providers](#providers), [resources](#resources) and [connectors](#connectors) maps well to APIs. For example, a typical API such as GitHub would define the provider as GitHub, a resource as `GetUser` or `ListRepositories` and the connector could be [HttpConnector][].
14+
Porter's [interface triad](#overview) of [providers](#providers), [resources](#resources) and [connectors](#connectors) maps well to APIs. For example, a typical API such as GitHub would define the provider as GitHub, a resource as `GetUser` or `ListRepositories` and the connector could be [HttpConnector][].
1615

1716
Porter provides a dual API for synchronous and [asynchronous](#asynchronous) imports, both of which are concurrency safe, so multiple imports can be paused and resumed simultaneously. Asynchronous mode allows large scale imports across multiple connections to work at maximum efficiency without waiting for each network call to complete.
1817

@@ -26,32 +25,32 @@ Contents
2625
--------
2726

2827
1. [Benefits](#benefits)
29-
1. [Quick start](#quick-start)
30-
1. [About this manual](#about-this-manual)
31-
1. [Usage](#usage)
32-
1. [Porter's API](#porters-api)
33-
1. [Overview](#overview)
34-
1. [Import specifications](#import-specifications)
35-
1. [Record collections](#record-collections)
36-
1. [Asynchronous](#asynchronous)
37-
1. [Transformers](#transformers)
38-
1. [Filtering](#filtering)
39-
1. [Durability](#durability)
40-
1. [Caching](#caching)
41-
1. [Architecture](#architecture)
42-
1. [Providers](#providers)
43-
1. [Resources](#resources)
44-
1. [Connectors](#connectors)
45-
1. [Requirements](#requirements)
46-
1. [Limitations](#limitations)
47-
1. [Testing](#testing)
48-
1. [Contributing](#contributing)
49-
1. [License](#license)
28+
2. [Quick start](#quick-start)
29+
3. [About this manual](#about-this-manual)
30+
4. [Usage](#usage)
31+
5. [Porter's API](#porters-api)
32+
6. [Overview](#overview)
33+
7. [Import specifications](#import-specifications)
34+
8. [Record collections](#record-collections)
35+
9. [Asynchronous](#asynchronous)
36+
10. [Transformers](#transformers)
37+
11. [Filtering](#filtering)
38+
12. [Durability](#durability)
39+
13. [Caching](#caching)
40+
14. [Architecture](#architecture)
41+
15. [Providers](#providers)
42+
16. [Resources](#resources)
43+
17. [Connectors](#connectors)
44+
18. [Requirements](#requirements)
45+
19. [Limitations](#limitations)
46+
20. [Testing](#testing)
47+
21. [Contributing](#contributing)
48+
22. [License](#license)
5049

5150
Benefits
5251
--------
5352

54-
* Defines an **interface trichotomy** for data imports: [providers](#providers) represent one or more [resources](#resources) that fetch data from [connectors](#connectors). These interfaces make it very easy to **test and mock** specific parts of the import lifecycle using industry standard tools, whether we want to mock at the connector level and feed in raw responses or mock at the resource level and feed in hydrated objects.
53+
* Defines an **interface triad** for data imports: [providers](#providers) represent one or more [resources](#resources) that fetch data from [connectors](#connectors). These interfaces make it very easy to **test and mock** specific parts of the import lifecycle using industry standard tools, whether we want to mock at the connector level and feed in raw responses or mock at the resource level and feed in hydrated objects.
5554
* Provides **memory-efficient data processing** interfaces that handle large data sets one record at a time, via iterators, which can be implemented using deferred execution with generators.
5655
* [Asynchronous](#asynchronous) imports offer highly efficient **CPU-bound data processing** for large scale imports across multiple connections concurrently, eliminating network latency performance bottlenecks. Concurrency can be **rate-limited** using [throttling](#throttling).
5756
* Protects against intermittent network failures with [durability](#durability) features that transparently and **automatically retry failed data fetches**.
@@ -479,21 +478,12 @@ It is important to define a canonical order for hashed inputs such that identica
479478

480479
To support Porter's durability features a connector may throw a subclass of `RecoverableConnectorException` to signal that the fetch operation can be retried. Execution will halt as normal if any other exception type is thrown. It is recommended to throw a recoverable exception type when the fetch operation is idempotent.
481480

482-
Requirements
483-
------------
484-
485-
- [PHP 7.1](http://php.net/)
486-
- [Composer](https://getcomposer.org/)
487-
488481
Limitations
489482
-----------
490483

491484
Current limitations that may affect some users and should be addressed in the near future.
492485

493486
- No end-to-end data steaming interface.
494-
- Caching does not support asynchronous imports.
495-
- [Sub-imports][] do not support async.
496-
- No import rate throttle for synchronous imports.
497487

498488
Testing
499489
-------
@@ -513,6 +503,13 @@ License
513503

514504
Porter is published under the open source GNU Lesser General Public License v3.0. However, the original Porter character and artwork is copyright &copy; 2022 [Bilge](https://github.com/Bilge) and may not be reproduced or modified without express written permission.
515505

506+
Support
507+
-------
508+
509+
Porter is supported by [JetBrains for Open Source][] products.
510+
511+
[![][JetBrains logo]][JetBrains for Open Source]
512+
516513
###### Quick links
517514

518515
[![][Porter icon]][Provider]
@@ -558,3 +555,5 @@ Porter is published under the open source GNU Lesser General Public License v3.0
558555
[Amp]: https://amphp.org
559556
[Amp documentation]: https://amphp.org/amp/
560557
[Async Throttle]: https://github.com/ScriptFUSION/Async-Throttle
558+
[JetBrains for Open Source]: https://jb.gg/OpenSource
559+
[JetBrains logo]: https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg "JetBrains logo"

src/Porter.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@
2121
/**
2222
* Imports data from a provider defined in the container of providers or the internal factory.
2323
*/
24-
class Porter
24+
final class Porter
2525
{
26-
/**
27-
* @var ContainerInterface Container of user-defined providers.
28-
*/
29-
private ContainerInterface $providers;
30-
3126
/**
3227
* @var ProviderFactory Internal factory of first-party providers.
3328
*/
@@ -38,9 +33,8 @@ class Porter
3833
*
3934
* @param ContainerInterface $providers Container of providers.
4035
*/
41-
public function __construct(ContainerInterface $providers)
36+
public function __construct(private readonly ContainerInterface $providers)
4237
{
43-
$this->providers = $providers;
4438
}
4539

4640
/**

test/Unit/PorterAwareTraitTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace ScriptFUSIONTest\Unit;
55

66
use PHPUnit\Framework\TestCase;
7+
use Psr\Container\ContainerInterface;
78
use ScriptFUSION\Porter\Porter;
89
use ScriptFUSION\Porter\PorterAwareTrait;
910

@@ -14,14 +15,12 @@ public function testGetSetPorter(): void
1415
/** @var PorterAwareTrait $porterAware */
1516
$porterAware = $this->getObjectForTrait(PorterAwareTrait::class);
1617

17-
$porterAware->setPorter($porter = \Mockery::mock(Porter::class));
18+
$porterAware->setPorter($porter = new Porter(\Mockery::mock(ContainerInterface::class)));
1819

1920
self::assertSame(
2021
$porter,
2122
\Closure::bind(
22-
function (): Porter {
23-
return $this->getPorter();
24-
},
23+
fn () => $this->getPorter(),
2524
$porterAware,
2625
$porterAware
2726
)()

0 commit comments

Comments
 (0)