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 getters to access CarbonPeriod like a DatePeriod object #2194

Closed
kylekatarnls opened this issue Sep 21, 2020 · 0 comments · Fixed by #2208
Closed

⭐ Add getters to access CarbonPeriod like a DatePeriod object #2194

kylekatarnls opened this issue Sep 21, 2020 · 0 comments · Fixed by #2208
Assignees
Milestone

Comments

@kylekatarnls
Copy link
Collaborator

I encountered an issue with the following code:

$period = new DatePeriod(...);
var_dump($period->start); // Contains the start date of the period
$period = new CarbonPeriod(...);
var_dump($period->start); // Error: Undefined property

Carbon version: 2.40.0

PHP version: 7.1.8

Actually: CarbonPeriod objects does not have any properties/getters to access the period definition like the DatePeriod can.

Expected: It would be great that as a polyfill CarbonPeriod would have equivalent possibility using a magic getter __get to access:

start
end
interval
recurrences
include_start_date
include_end_date
current
@kylekatarnls kylekatarnls added enhancement good first issue If you wish to contribute to Carbon you could start with this issue labels Sep 21, 2020
@kylekatarnls kylekatarnls added this to the 2.41.0 milestone Sep 21, 2020
@kylekatarnls kylekatarnls removed the good first issue If you wish to contribute to Carbon you could start with this issue label Oct 1, 2020
@kylekatarnls kylekatarnls self-assigned this Oct 1, 2020
kylekatarnls added a commit to kylekatarnls/Carbon that referenced this issue Oct 1, 2020
kylekatarnls added a commit to kylekatarnls/Carbon that referenced this issue Oct 1, 2020
kylekatarnls added a commit to kylekatarnls/Carbon that referenced this issue Oct 1, 2020
kylekatarnls added a commit that referenced this issue Oct 1, 2020
…getter

#2194 Add readonly public properties to CarbonPeriod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant