Closed solodkiy closed 2 years ago
IMO, the Native
prefix makes sense, I'm :+1: on this it helps readability and reduce ambiguity. I've wondered myself while trying to autocomplete method calls if the suggested DatePeriod
for example was a library class or the native one.
However I would keep the getDateTime
as it is since it means it is getting
the DateTime part of the ZonedDateTime
. Using the to
prefix would suggest it's transforming the object into another one which is not the case here.
@BenMorel wdyt ?
Some of get*()
/to*()
discussion was there: https://github.com/brick/date-time/pull/48
LGTM as well with the Native
prefix. @solodkiy You're welcome to open a PR to create the new (to|from)Native*()
methods, and deprecate existing ones. We'll remove them in 0.5.0
.
The getDateTime()
method is in line with the discussion we had in #48, so it looks good as it is!
In ZonedDateTime class we have two methods which looks almost the same, but different in return types:
public function toDateTime() : \DateTime
public function getDateTime() : LocalDateTime
To avoid misunderstanding and confuse I propose rename
toDateTime
totoNativeDateTime
. This approach could be used in other conversions in and from native types. For example:Period::fromDateInterval
->Period::fromNativeDateInterval
Period::toDateInterval
->Period::toNativeDateInterval
LocalDateRange::toDatePeriod
->LocalDateRange::toNativeDatePeriod
TimeZone::fromDateTimeZone
->TimeZone::fromNativeDateTimeZone
etc..Another variant is use Php prefix (
toDateTime
->toPhpDateTime
).