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

Add hasExpired to AccessToken #319

Merged
merged 1 commit into from Jun 4, 2015
Merged

Add hasExpired to AccessToken #319

merged 1 commit into from Jun 4, 2015

Conversation

rtheunissen
Copy link
Contributor

Seemed like an easy value-add to the token, even though it doesn't technically solve a problem. Makes it easy to check if a token should be refreshed when a request is made.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.23%) to 93.04% when pulling c1b1af5 on rtheunissen:token_has_expired into a2c54cc on thephpleague:1.0.

@ramsey
Copy link
Contributor

ramsey commented Jun 4, 2015

Looks good. Thanks!

ramsey added a commit that referenced this pull request Jun 4, 2015
@ramsey ramsey merged commit 0c3f84b into thephpleague:1.0 Jun 4, 2015
public function hasExpired()
{
if (!isset($this->expires)) {
throw new InvalidArgumentException('"expires" is not set on the token');
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that using InvalidArgumentException is the best choice here, because there is no argument at play. A better choice would be RuntimeException.

Copy link
Contributor

Choose a reason for hiding this comment

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

I gave that some thought, too, but I wasn't sure what would best fit. I think you're right: RuntimeException would be best.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about this too when I was writing it and went through all descriptions for them. I figured that it's an InvalidArgumentException because 'expires' is an invalid argument because it's not set. Another thought was to not throw and exception at all, but return false instead if not set.

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

4 participants