-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#44 Add order item read & link order with channel resource #47
Conversation
@ddattee I've cleaned a bit the documentation to make it more readable |
src/Api/Order/OrderItem.php
Outdated
private $reference; | ||
private $quantity; | ||
private $unitPrice; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add var type in comments
* @return OrderItemCollection A new instance of self, holding relevant items | ||
*/ | ||
public static function fromProperties(array $items) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe withItems
would more accurate ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with* are usually instance modifiers for immutable objects (check PSR-7 implementation).
src/Resource/AbstractResource.php
Outdated
* @param string $property | ||
* @param string $property The property name | ||
* @param bool $initialize Indicates if the resource must be fetched from server | ||
* in order to access to this property (when no present in partial representation) | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'...when NOT present...'
@ddattee review done |
Link to the issue
#44
Reason for this PR
What does the PR do
Implements accessors for both
Unrelated changes
The
AbstractResource::getProperty()
method now accept a second argument, which indicates if the resource must loaded from the server to access to that property.An usage example is here, where orders items are only provided when fetching a single resource:
https://github.com/shoppingflux/php-sdk/pull/47/files#diff-d7931d116e86a29bdd1e9ae70a77fcaaR104
Note that server request is only performed once, and not on every property access demand.
How to test
The following script will loop agains orders and print items / channel data :