for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the DateTime library.
*
* (c) Artem Henvald <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Fresh\DateTime;
use Fresh\DateTime\Exception\LogicException;
/**
* DateRange.
* @author Artem Henvald <[email protected]>
class DateRange
{
/** @var \DateTimeInterface */
private $since;
private $till;
* @param \DateTimeInterface $since
* @param \DateTimeInterface $till
public function __construct(\DateTimeInterface $since, \DateTimeInterface $till)
$this->since = $since;
$this->till = $till;
}
* @return \DateTimeInterface
public function getSince(): \DateTimeInterface
return $this->since;
* @return $this
public function setSince(\DateTimeInterface $since): self
return $this;
public function getTill(): \DateTimeInterface
return $this->till;
public function setTill(\DateTimeInterface $till): self
* @throws LogicException
public function assertSameTimezones(): void
if ($this->since->getTimezone()->getName() !== $this->till->getTimezone()->getName()) {
throw new LogicException('Date range has different timezones');