- var_dump: documentation ( source)
<?php
class Timer
{
private $_state;
private $_date;
public function __construct($state, \DateTime $date)
{
$this->_state = $state;
$this->_date = clone $date;
}
public function getType()
{
return $this->_state;
}
public function getInterval()
{
return (new \DateTime('2015-01-01'))->diff(clone $this->_date);
}
public function isPositive()
{
return !(bool) $this->getInterval()->invert;
}
public function isNegative()
{
return (bool) $this->getInterval()->invert;
}
}
$timer = new Timer('lalala', new \DateTime('2015-01-01'));
var_dump(
$timer->isPositive(),
$timer->isNegative()
);