-
Notifications
You must be signed in to change notification settings - Fork 85
reduce getHeaders() call in Request::setServer() #183
reduce getHeaders() call in Request::setServer() #183
Conversation
samsonasik
commented
Aug 18, 2019
- Is this related to quality assurance?
src/PhpEnvironment/Request.php
Outdated
| } | ||
|
|
||
| $this->getHeaders()->addHeaders($headers); | ||
| $headers = $this->getHeaders()->addHeaders($headers); |
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.
Personally I am not sure if it is good improvement, I mean, for me it is less readable - as definition of the variable and usage of it is several lines below.
Also it takes advantages of fluent interfaces, and as far as I know we tend to drop them.
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.
Ok, I reverted the change of re-assignment headers.
src/PhpEnvironment/Request.php
Outdated
| // Set the host | ||
| if ($this->getHeaders()->get('host')) { | ||
| $host = $this->getHeaders()->get('host')->getFieldValue(); | ||
| if ($headers->get('host')) { |
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.
We have then twice ->get('host').
What about:
$headerHost = $this->getHeaders()->get('host');
if ($headerHost) {
$host = $headerHost->getFieldValue();
...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.
Ok, implemented assign first to $headerHost
|
Thanks, @samsonasik! |
reduce getHeaders() call in Request::setServer()