| Total Complexity | 5 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class Schedule extends Component |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * All of the events on the schedule. |
||
| 15 | * |
||
| 16 | * @var Event[] |
||
| 17 | */ |
||
| 18 | protected $_events = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Add a new callback event to the schedule. |
||
| 22 | * |
||
| 23 | * @param string $callback |
||
| 24 | * @param array $parameters |
||
| 25 | * |
||
| 26 | * @return Event |
||
| 27 | */ |
||
| 28 | public function call($callback, array $parameters = []) |
||
| 29 | { |
||
| 30 | $this->_events[] = $event = new CallbackEvent($callback, $parameters); |
||
| 31 | |||
| 32 | return $event; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Add a new cli command event to the schedule. |
||
| 37 | * |
||
| 38 | * @param string $command |
||
| 39 | * |
||
| 40 | * @return Event |
||
| 41 | */ |
||
| 42 | public function command($command) |
||
| 43 | { |
||
| 44 | return $this->exec(PHP_BINARY . ' yii ' . $command); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Add a new command event to the schedule. |
||
| 49 | * |
||
| 50 | * @param string $command |
||
| 51 | * |
||
| 52 | * @return Event |
||
| 53 | */ |
||
| 54 | public function exec($command) |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Get events |
||
| 63 | * |
||
| 64 | * @return Event[] |
||
| 65 | */ |
||
| 66 | public function getEvents() |
||
| 67 | { |
||
| 68 | return $this->_events; |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Get all of the events on the schedule that are due. |
||
| 73 | * |
||
| 74 | * @param \yii\base\Application $app |
||
| 75 | * |
||
| 76 | * @return Event[] |
||
| 77 | */ |
||
| 78 | public function dueEvents(Application $app) |
||
| 82 | }); |
||
| 83 | } |
||
| 84 | } |
||
| 85 |