2017 © Pedro Peláez
 

library smart-sleep

Smart sleep

image

anime-db/smart-sleep

Smart sleep

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Latest Stable Version Total Downloads Build Status Coverage Status Scrutinizer Code Quality SensioLabs Insight StyleCI License, (*1)

SmartSleep

Installation

Pretty simple with Composer, run:, (*2)

composer require anime-db/smart-sleep

How-to

First build schedule, (*3)

use AnimeDb\SmartSleep\Rule\EverydayRule;
use AnimeDb\SmartSleep\Schedule;

$schedule = new Schedule([
    new EverydayRule(0, 3, 260), // [00:00, 03:00)
    new EverydayRule(3, 9, 900), // [03:00, 09:00)
    new EverydayRule(9, 19, 160), // [09:00, 19:00)
    new EverydayRule(19, 23, 70), // [19:00, 23:00)
    new EverydayRule(23, 24, 60), // [23:00, 24:00)
]);

Configure SmartSleep, (*4)

use AnimeDb\SmartSleep\SmartSleep;

$smart = new SmartSleep($schedule);

And now we can sleep, (*5)

$seconds = $smart->sleepForSeconds(new \DateTimeImmutable());

sleep($seconds);

Rules

SpecificDayRule

The rule corresponds to specific day in the specified time interval. Can be used for public holidays., (*6)

$rule = new SpecificDayRule(new \DateTimeImmutable('2017-01-01'), $start_hour, $end_hour, $max_sleep_seconds)

EverydayRule

The rule corresponds to any day in the specified time interval., (*7)

$rule = new EverydayRule($start_hour, $end_hour, $max_sleep_seconds)

HolidayRule

The rule corresponds to the holiday at the specified time interval., (*8)

$rule = new HolidayRule($start_hour, $end_hour, $max_sleep_seconds)

WeekdayRule

The rule corresponds to the weekday at the specified time interval., (*9)

$rule = new WeekdayRule($start_hour, $end_hour, $max_sleep_seconds)

OnceDayRule

The rule always corresponds to the specified time. Returns the seconds in the next day., (*10)

$rule = new OnceDayRule()

OnceWeekRule

The rule always corresponds to the specified time. Returns the seconds in the next week., (*11)

$rule = new OnceWeekRule()

OnceMonthRule

The rule always corresponds to the specified time. Returns the seconds in the next month., (*12)

$rule = new OnceMonthRule()

License

This bundle is under the MIT license. See the complete license in the file: LICENSE, (*13)

The Versions

25/07 2017

dev-master

9999999-dev http://github.com/anime-db/smart-sleep

Smart sleep

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

php sleep

25/07 2017

v2.1.0

2.1.0.0 http://github.com/anime-db/smart-sleep

Smart sleep

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

php sleep

25/07 2017

v2.0.0

2.0.0.0 http://github.com/anime-db/smart-sleep

Smart sleep

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

php sleep

25/07 2017

1.0.x-dev

1.0.9999999.9999999-dev http://github.com/anime-db/smart-sleep

Smart sleep

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

php sleep

25/07 2017

v1.0.2

1.0.2.0 http://github.com/anime-db/smart-sleep

Smart sleep

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

php sleep

11/07 2016

v1.0.1

1.0.1.0 http://github.com/anime-db/smart-sleep

Smart sleep

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

php sleep

23/06 2016

v1.0.0

1.0.0.0 http://github.com/anime-db/smart-sleep

Smart sleep

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

php sleep