/** * @param \AGmakonts\DddBricks\Service\ServiceInterface $target * @param array $params */ public function __construct(ServiceInterface $target, array $params = []) { $this->target = $target; $this->occurrenceTime = DateTime::get(); $this->identifier = Text::get(Uuid::uuid4()->toString()); $this->params = $params; }
/** * @param \AGmakonts\STL\String\Text $date * @param \AGmakonts\STL\String\Text $format * * @return DateTime */ public static function getFromFormat(Text $date, Text $format) { $dateTime = \DateTime::createFromFormat($format->value(), $date->value()); if (FALSE === $dateTime) { throw new \InvalidArgumentException("Wrong format or date provided"); } $timestamp = Integer::get($dateTime->getTimestamp()); return self::getInstanceForValue($timestamp); }
/** * @return \AGmakonts\STL\DateTime\DateTime */ public function nextAnniversary() : DateTime { $nativeDate = new \DateTime($this->date()->getTimestamp()->value()); $now = new \DateTime(); $interval = new \DateInterval('P1Y'); while ($nativeDate->getTimestamp() < $now->getTimestamp()) { $nativeDate = $nativeDate->add($interval); } return DateTime::get(Integer::get($nativeDate->getTimestamp())); }
/** * @covers ::getFromFormat() */ public function testGetFromFormat() { $testClass1 = \AGmakonts\STL\DateTime\DateTime::getFromFormat(\AGmakonts\STL\String\Text::get("2005-08-15T15:52:01+0000"), \AGmakonts\STL\String\Text::get('Y-m-d\\TH:i:sO')); $this->assertInstanceOf(\AGmakonts\STL\DateTime\DateTime::class, $testClass1); $this->assertSame(1124121121, $testClass1->getTimestamp()->value()); }
/** * @param \AGmakonts\DddBricks\Entity\EntityInterface $target */ public function __construct(EntityInterface $target) { $this->target = $target; $this->occurrenceTime = DateTime::get(); $this->identifier = Text::get(Uuid::uuid4()->toString()); }
/** * @param \AGmakonts\STL\DateTime\DateTime $date */ public function __construct(DateTime $date) { $this->message = sprintf(self::MESSAGE_FORMAT, $date->value()); }