for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Vctls\IntervalGraph\Util;
use DateInterval;
use DateTime;
use Exception;
use Vctls\IntervalGraph\IntervalGraph;
/**
* Utility class for creating interval graphs.
*
* @package Vctls\IntervalGraph
*/
class Date
{
* Create an interval of dates from two integers and a value.
* @param $start
* @param $end
* @param mixed $value
* @return array
public static function intv(int $start, int $end, $value = null)
try {
$start = new DateTime("today + $start days");
$end = (new DateTime("today + $end days"))->setTime(23,59,59);
} catch (Exception $e) {}
return [$start, $end, $value];
}
* Create an IntervalGraph for handling dates.
* @param $args
* @return IntervalGraph
public static function intvg($args) {
$substractStep = function (DateTime $bound) {
return (clone $bound)->sub(new DateInterval('PT1S'));
};
$addStep = function (DateTime $bound) {
return (clone $bound)->add(new DateInterval('PT1S'));
return (new IntervalGraph($args))
->setAddStep($addStep)
->setSubstractStep($substractStep);
* Generate a random date.
* @param int $min
* @param int $max
* @return DateTime
public static function rdm($min = 1514764800, $max = 1577750400)
return $date = (new DateTime)->setTimestamp(mt_rand($min, $max));
$date
} catch (Exception $e) {
return null;