-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add getSegmentsByClass #122
Add getSegmentsByClass #122
Conversation
This is definitely useful. Thank you for the PR. Please go ahead and update the docs |
src/HL7/Message.php
Outdated
* @param string $name Segment class | ||
* @return array List of segments identified by class | ||
*/ | ||
public function getSegmentsByClass(string $class): array |
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.
Rename $class
to $segmentClass
src/HL7/Message.php
Outdated
{ | ||
$segmentsByClass = []; | ||
|
||
foreach ($this->segments as $seg) { |
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.
Rename $seg
to the full word $segment
Thanks, @senaranya. I've now added:
I've made the suggested changes and ran |
Thanks for the changes, although it looks like the documentation changes are too big (probably because those weren't updated in the earlier PRs), and thus the actual diff for this is kind of lost in the noise. Let's revert those documentation changes please, unless you've added anything in the Readme file. We'll run phpdoc-md in a separate ticket. Also check if the Action (CI pipeline) failures are anything relevant |
b6aa463
to
2f81885
Compare
2f81885
to
c373704
Compare
@senaranya I've reverted the documentation update and I've fixed the ci errors. |
This introduces a function that allows you to call:
instead of
just to give a little more safety. I wanted to keep this very simple to see if this approach was seen as useful. But I could see functions like
That specifies a specific segment type as the return type, so that you could then call
Because currently static analyzers like phpstan will complain that
Segment
doesn't have a functiongetRace()
.Let me know if this you think this is useful and/or a good direction, and I can update docs.