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

Adds new strategy for PHP’s DateTimeImmutable object #17

Merged

Conversation

froschdesign
Copy link
Member

@froschdesign froschdesign commented Jun 25, 2020

Q A
New Feature yes

Example

class BlogPost
{
    private $creationDate;

    public function getCreationDate()
    {
        return $this->creationDate;
    }
}

$hydrator = new Laminas\Hydrator\ReflectionHydrator();
$hydrator->addStrategy(
    'creationDate',
    new Laminas\Hydrator\Strategy\DateTimeImmutableFormatterStrategy(
        new Laminas\Hydrator\Strategy\DateTimeFormatterStrategy('Y-m-d')
    )
);

$blogPost = new BlogPost();
$hydrator->hydrate(['creationDate' => '2020-06-25'], $blogPost);

var_dump($blogPost->getCreationDate() instanceof DateTimeImmutable); // true

Copy link
Member

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Only thing missing for me is docs!

@froschdesign froschdesign force-pushed the feature/datetime-immutable-strategy branch 3 times, most recently from 3ffbee6 to 20d25d6 Compare July 11, 2020 09:17
Signed-off-by: Frank Brückner <dev@froschdesignstudio.de>
Signed-off-by: Frank Brückner <dev@froschdesignstudio.de>
Signed-off-by: Frank Brückner <dev@froschdesignstudio.de>
@weierophinney weierophinney force-pushed the feature/datetime-immutable-strategy branch from 20d25d6 to e918441 Compare July 14, 2020 20:48
@weierophinney weierophinney changed the base branch from master to develop July 14, 2020 20:48
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney merged commit 5663c24 into laminas:develop Jul 14, 2020
@froschdesign froschdesign deleted the feature/datetime-immutable-strategy branch July 15, 2020 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DateTimeImmutableFormatterStrategy
2 participants