Cake\Chronos\Traits\MagicPropertyTrait::__get PHP Method

__get() public method

Get a part of the ChronosInterface object
public __get ( string $name ) : string | integer | DateTimeZone
$name string The property name to read.
return string | integer | DateTimeZone The property value.
    public function __get($name)
    {
        switch (true) {
            case array_key_exists($name, $formats = ['year' => 'Y', 'yearIso' => 'o', 'month' => 'n', 'day' => 'j', 'hour' => 'G', 'minute' => 'i', 'second' => 's', 'micro' => 'u', 'dayOfWeek' => 'N', 'dayOfYear' => 'z', 'weekOfYear' => 'W', 'daysInMonth' => 't', 'timestamp' => 'U']):
                return (int) $this->format($formats[$name]);
            case $name === 'weekOfMonth':
                return (int) ceil($this->day / ChronosInterface::DAYS_PER_WEEK);
            case $name === 'age':
                return $this->diffInYears();
            case $name === 'quarter':
                return (int) ceil($this->month / 3);
            case $name === 'offset':
                return $this->getOffset();
            case $name === 'offsetHours':
                return $this->getOffset() / ChronosInterface::SECONDS_PER_MINUTE / ChronosInterface::MINUTES_PER_HOUR;
            case $name === 'dst':
                return $this->format('I') === '1';
            case $name === 'local':
                return $this->offset === $this->copy()->setTimezone(date_default_timezone_get())->offset;
            case $name === 'utc':
                return $this->offset === 0;
            case $name === 'timezone' || $name === 'tz':
                return $this->getTimezone();
            case $name === 'timezoneName' || $name === 'tzName':
                return $this->getTimezone()->getName();
            default:
                throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name));
        }
    }
MagicPropertyTrait