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

Inconsistency in news model datetime getter methods #2123

Open
GuidoJansenPI opened this issue Jun 14, 2023 · 0 comments
Open

Inconsistency in news model datetime getter methods #2123

GuidoJansenPI opened this issue Jun 14, 2023 · 0 comments

Comments

@GuidoJansenPI
Copy link

There is a slight inconsistency in the way that days, months and years can be derived in the news model.

// File: EXT:news/Classes/Domain/Model/News.php
// Lines: 359 through 387
    /**
     * Get year of datetime
     *
     * @return false|string
     */
    public function getYearOfDatetime()
    {
        return $this->getDatetime()->format('Y');
    }

    /**
     * Get month of datetime
     *
     * @return false|string
     */
    public function getMonthOfDatetime()
    {
        return $this->getDatetime()->format('m');
    }

    /**
     * Get day of datetime
     *
     * @return int
     */
    public function getDayOfDatetime(): int
    {
        return (int)$this->datetime->format('d');
    }

Both the methods getYearOfDatetime and getMonthOfDatetime get the datetime information via getDatetime method, whilst the getDayOfDatetime method derives this data directly by access to the datetime property.

This seems inconsistent to me. I'd rather let all of them access the data either directly through the property or via the getter method.
Maybe there is a reason for that. Georg will know.

@GuidoJansenPI GuidoJansenPI changed the title Inconsistency in news model datetime methos Inconsistency in news model datetime getter methods Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant