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

Reduce method responsibility #115

Merged
merged 1 commit into from Aug 4, 2019
Merged

Reduce method responsibility #115

merged 1 commit into from Aug 4, 2019

Conversation

mapogolions
Copy link
Contributor

@mapogolions mapogolions commented Aug 4, 2019

When we create an object through the Response constructor

$response = new Response(200)
// protected $this->status = 200
// protected $this->reasonPhrase = '', by default

we don't attempt to guess(set) the value of the reason phrase. We are just using default value(empty string). All needed work is done by the getReasonPhrase method. It maps a status to a reason.

On the other hand, when we call the withStatus method we have a different strategy

$forbidden = new Response(403);
// ...
$ok = $forbidden->withStatus(200);
// protected $this->status = 200;
// protected $this->reasonPhrase = 'OK'

I suggest to rely on the work of the getReasonPhrase method;

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0007%) to 99.73% when pulling a46ac36 on mapogolions:enhancement/inconsistent-behaviour into 7936bf9 on slimphp:master.

@l0gicgate l0gicgate added this to the 0.5 milestone Aug 4, 2019
@l0gicgate l0gicgate merged commit a334578 into slimphp:master Aug 4, 2019
@mapogolions mapogolions deleted the enhancement/inconsistent-behaviour branch August 4, 2019 17:36
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.

None yet

3 participants