Closed amirakbulut closed 2 years ago
Hi,
Why are all the properties of the Period object protected?
For example, I want to grab the start & end of a Period object.
$period = Period::make('2021-11-01 08:00:00', '2021-11-01 18:00:00', Precision::MINUTE(), Boundaries::EXCLUDE_ALL());
$period->start returns:
$period->start
Uncaught Error: Cannot access protected property Spatie\Period\Period::$start
$period->end returns:
$period->end
Uncaught Error: Cannot access protected property Spatie\Period\Period::$end
I tried $period->getStart() as well, which returns:
$period->getStart()
Uncaught Error: Call to undefined method Spatie\Period\Period::getStart()
Why?
You need to use ->start() and ->end(): https://github.com/spatie/period/blob/master/src/PeriodTraits/PeriodGetters.php#L36
->start()
->end()
Hi,
Why are all the properties of the Period object protected?
For example, I want to grab the start & end of a Period object.
$period->start
returns:$period->end
returns:I tried
$period->getStart()
as well, which returns:Why?