Skip to content
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

Ability to find an envelope instance from the given stack #216

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

viktorprogger
Copy link
Contributor

Q A
Is bugfix?
New feature? ✔️
Breaks BC?

This PR allows to obtain an envelope instance from envelope stack:

$idEnvelope = $message instanceof EnvelopeInterface ? $message->getEnvelopeFromStack(IdEnvelope::class) : IdEnvelope::fromMessage($message);

If the envelope you need uses EnvelopeTrait, it's more simple: code IdEnvelope::getEnvelopeFromMessage($message) will have the same effect as above.

@viktorprogger viktorprogger self-assigned this Sep 18, 2024
public function getEnvelopeFromStack(string $className): EnvelopeInterface
{
if (!is_a($className, EnvelopeInterface::class, true)) {
throw new NotEnvelopInterfaceException($className);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new NotEnvelopInterfaceException($className);
throw new NotEnvelopeException($className);

use InvalidArgumentException;
use Throwable;

final class NotEnvelopInterfaceException extends InvalidArgumentException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final class NotEnvelopInterfaceException extends InvalidArgumentException
final class NotEnvelopeException extends InvalidArgumentException

@viktorprogger viktorprogger added the status:code review The pull request needs review. label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:code review The pull request needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants