Wallogit.com
2017 © Pedro Peláez
DateTime helpers
Install package jaroslavlibal/datetime with Composer and register the parts you need as the services., (*1)
composer require jaroslavlibal/datetime
Retrieve the DateTime and DateTimeImmutable objects from the mockable and testable factory instead of direct new \DateTime() creation., (*2)
class Foo
{
use JaroslavLibal\DateTime\Factory\DateTimeFactory;
use JaroslavLibal\DateTime\Factory\DateTimeFactory;
private DateTimeFactory;
private DateTimeImmutableFactory;
public function __construct(DateTimeFactory $dateTimeFactory, DateTimeImmutableFactory $dateTimeImmutableFactory)
private function bar() {
$dateTimeFactory->create();
$dateTimeImmutableFactory->create();
}
}