kalibora / datetime-immutable-factory
Create DateTimeImmutable from DateTimeInterface
Installs: 50 316
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^v3.16
- phpstan/phpstan: ^1.10
- phpstan/phpstan-strict-rules: ^1.5
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-24 05:30:54 UTC
README
Enforce DateTimeInterface to DateTimeImmutable.
Usage
$immutable1 = DateTimeImmutableFactory::create(new \DateTime()); $immutable2 = DateTimeImmutableFactory::create(new \DateTimeImmutable()); function addOneDay(\DateTimeInterface $date) : \DateTimeInterface { // Call to an undefined method DateTimeInterface::modify() // $date->modify(); return DateTimeImmutableFactory::create($date)->modify('+1 day'); }