for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* AnimeDb package.
*
* @author Peter Gribanov <[email protected]>
* @copyright Copyright (c) 2011, Peter Gribanov
*/
namespace AnimeDb\SmartSleep;
use AnimeDb\SmartSleep\Rule\RuleInterface;
class SmartSleep
{
* @var Schedule
protected $schedule = [];
* @param Schedule $schedule
public function __construct(Schedule $schedule)
$this->schedule = $schedule;
}
* @param \DateTime $now
* @return int
public function getSleepSeconds(\DateTime $now)
$rule = $this->schedule->getMatchedRule($now);
if ($rule instanceof RuleInterface) {
$seconds = $rule->getSeconds();
return $seconds > 0 ? $seconds : 0;
return 0;