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

deserialize sqs message attributes #901

Merged
merged 1 commit into from
Jun 14, 2019

Conversation

bendavies
Copy link
Contributor

Allow deserializing all messages attributes, which we can use for logging and debugging.

@makasim makasim merged commit 309d3bd into php-enqueue:master Jun 14, 2019

public function getAttribute(string $name, $default = null)
{
return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't isset be sufficient? It is said it's a lot faster than array_key_exists with the difference that it will report null values as not set.

https://ilia.ws/archives/247-Performance-Analysis-of-isset-vs-array_key_exists.html
http://thinkofdev.com/php-fast-way-to-determine-a-key-elements-existance-in-an-array/

At least it was in 2012, but I don't think this changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure there are better ways now, return $this->attributes[$name] ?? $default, but i was copying the current style of the code base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants