Added resource type parameter to Provider::getConnector
Following up on the TODO comment from #41, this PR doesn't pass the resource to Provider::getConnector, but rather, just the resource's type. I don't feel comfortable passing the entire resource because the only real use-case for passing the resource is to make decisions based on its type.
Passing the entire object might cause people to do questionable things with the resource so we just pass the type name as a string instead. Unfortunately, this makes type checking code a little more cumbersome to write. Instead of $resource instanceof Foo we must write is_a($resourceType, Foo::class, true). Moreover, we lose the ability to distinguish between difference instances of Foo, but it is supposed no valid use cases exist for this.
The use-case for passing the resource type is applications that want to distinguish between different groups of resources that the API itself does not make. That is, certain applications may wish to group certain members of a provider's resources for application-defined reasons and pass different connectors to them.
Must decide whether or not we want this before v4 is released because it's a breaking change otherwise.
Codecov Report
Merging #47 into 4.0 will not change coverage. The diff coverage is
100%.
@@ Coverage Diff @@
## 4.0 #47 +/- ##
===================================
Coverage 100% 100%
===================================
Files 29 29
Lines 371 371
===================================
Hits 371 371
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/Connector/CachingConnector.php | 100% <ø> (ø) |
:arrow_up: |
| src/Provider/StaticDataProvider.php | 100% <100%> (ø) |
:arrow_up: |
| src/Porter.php | 100% <100%> (ø) |
:arrow_up: |
| src/Collection/RecordCollection.php | 100% <100%> (ø) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 61f6432...4be5207. Read the comment docs.