| 1 | <?php  | 
            ||
| 12 | class Schedule  | 
            ||
| 13 | { | 
            ||
| 14 | /**  | 
            ||
| 15 | * Stack of events  | 
            ||
| 16 | * @var Event[]  | 
            ||
| 17 | */  | 
            ||
| 18 | protected $events = [];  | 
            ||
| 19 | |||
| 20 | /**  | 
            ||
| 21 | * @var string|null  | 
            ||
| 22 | */  | 
            ||
| 23 | protected $name;  | 
            ||
| 24 | |||
| 25 | 2 | public function __construct(/* string */ $name = '<anonymous schedule>')  | 
            |
| 26 |     { | 
            ||
| 27 | 2 | Assert::nullOrString($name);  | 
            |
| 28 | 2 | $this->name = $name;  | 
            |
| 29 | 2 | }  | 
            |
| 30 | |||
| 31 | /**  | 
            ||
| 32 | * Get the name of this schedule  | 
            ||
| 33 | *  | 
            ||
| 34 | * @return string|null  | 
            ||
| 35 | */  | 
            ||
| 36 | public function getName()  | 
            ||
| 40 | |||
| 41 | /**  | 
            ||
| 42 | * Add a single Event to the stack  | 
            ||
| 43 | *  | 
            ||
| 44 | * @param Event $event  | 
            ||
| 45 | * @return $this  | 
            ||
| 46 | */  | 
            ||
| 47 | 2 | public function add(Event $event)  | 
            |
| 53 | |||
| 54 | /**  | 
            ||
| 55 | * Creates a new Event, adds it to the schedule stack and returns you the instance so you can configure it  | 
            ||
| 56 | *  | 
            ||
| 57 | * @param callable|string $event  | 
            ||
| 58 | * @return Event  | 
            ||
| 59 | */  | 
            ||
| 60 | 2 | public function run($event)  | 
            |
| 71 | |||
| 72 | /**  | 
            ||
| 73 | * @return Event[]  | 
            ||
| 74 | */  | 
            ||
| 75 | public function allEvents()  | 
            ||
| 79 | |||
| 80 | /**  | 
            ||
| 81 | * Get all of the events on the schedule that are due.  | 
            ||
| 82 | *  | 
            ||
| 83 | * @return Event[]  | 
            ||
| 84 | */  | 
            ||
| 85 | public function dueEvents()  | 
            ||
| 91 | }  | 
            ||
| 92 |