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

Consider the use of "instanceof" instead of "get_class" #49

Closed
samag opened this issue Dec 26, 2016 · 2 comments
Closed

Consider the use of "instanceof" instead of "get_class" #49

samag opened this issue Dec 26, 2016 · 2 comments
Assignees
Milestone

Comments

@samag
Copy link

samag commented Dec 26, 2016

Looking at

// If given date is a DateTime object; check if it falls in the weekend
if (get_class($date) === 'DateTime') {
    if (in_array($date->format('w'), $this->weekend_days)) {
        return false;
    }
}

the condition fails for any subclasses of DateTime (like the very popular Carbon class) which needlessly limits your APIs scope. Please consider the instanceof operator to allow for classes that derive from DateTime.

@stelgenhof
Copy link
Member

It does seem indeed a better way to verify the class with the instanceof operator. Thanks for the suggestion!

@stelgenhof stelgenhof self-assigned this Dec 29, 2016
@stelgenhof stelgenhof added this to the v1.6.0 milestone Dec 29, 2016
@stelgenhof
Copy link
Member

Resolved.

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

No branches or pull requests

2 participants