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\Rule;
class SmartSleep
{
* @var Schedule
private $schedule = [];
* @param Schedule $schedule
public function __construct(Schedule $schedule)
$this->schedule = $schedule;
}
* @param \DateTime $now
* @return int
public function sleepForSeconds(\DateTime $now)
$rule = $this->schedule->matchedRule($now);
if ($rule instanceof Rule) {
$seconds = $rule->seconds();
return $seconds > 0 ? $seconds : 0;
return 0;