Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
base | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
get_name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
set_name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
is_runnable | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
should_run | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\cron\task; |
15 | |
16 | /** |
17 | * Cron task base class. Provides sensible defaults for cron tasks |
18 | * and partially implements cron task interface, making writing cron tasks easier. |
19 | * |
20 | * At a minimum, subclasses must override the run() method. |
21 | * |
22 | * Cron tasks need not inherit from this base class. If desired, |
23 | * they may implement cron task interface directly. |
24 | */ |
25 | abstract class base implements \phpbb\cron\task\task |
26 | { |
27 | private $name; |
28 | |
29 | /** |
30 | * Returns the name of the task. |
31 | * |
32 | * @return string Name of wrapped task. |
33 | */ |
34 | public function get_name() |
35 | { |
36 | return $this->name; |
37 | } |
38 | |
39 | /** |
40 | * Sets the name of the task. |
41 | * |
42 | * @param string $name The task name |
43 | */ |
44 | public function set_name($name) |
45 | { |
46 | $this->name = $name; |
47 | } |
48 | |
49 | /** |
50 | * Returns whether this cron task can run, given current board configuration. |
51 | * |
52 | * For example, a cron task that prunes forums can only run when |
53 | * forum pruning is enabled. |
54 | * |
55 | * @return bool |
56 | */ |
57 | public function is_runnable() |
58 | { |
59 | return true; |
60 | } |
61 | |
62 | /** |
63 | * Returns whether this cron task should run now, because enough time |
64 | * has passed since it was last run. |
65 | * |
66 | * @return bool |
67 | */ |
68 | public function should_run() |
69 | { |
70 | return true; |
71 | } |
72 | } |