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

[NFR] Aura\Web\Request\Values::getBoolean() #34

Closed
iansltx opened this issue Jul 9, 2014 · 2 comments
Closed

[NFR] Aura\Web\Request\Values::getBoolean() #34

iansltx opened this issue Jul 9, 2014 · 2 comments

Comments

@iansltx
Copy link
Contributor

iansltx commented Jul 9, 2014

I'm consuming "pseudo-boolean" values from the query string, which if not handled carefully runs into issues because "false" evaluates to true, so I have to do something like this:

// default to true if param not provided, run condition if false
if (in_array($request->query->get('param', 1), ['false', 0])) {
    ...
}

...and casting to boolean doesn't work for avoiding the above.

If anyone else has this issue/is interested in a fix, I'll build out and PR getBoolean() (getBool()?) so that instead we've got:

if (false === $request->query->getBoolean('param', true)) {
    ...
}

or

if (!$request->query->getBoolean('param', true)) {
    ...
}

with a default of false of the second argument isn't provided.

Anyone interested?

@harikt
Copy link
Member

harikt commented Jul 10, 2014

not sure whether this is to be in core. The query parameters is up-to the developers to handle properly is my current thought.

@pmjones
Copy link
Member

pmjones commented Jul 22, 2014

I discussed this with @iansltx in person. I was originally against, but I can now see the benefits here. I will put up an experimental branch for this issue with getBool(), getInt(), and getFloat() implemented.

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

No branches or pull requests

3 participants