1 | <?php |
||
36 | class condition extends \core_availability\condition { |
||
37 | |||
38 | protected $viewslimit; |
||
39 | |||
40 | /** |
||
41 | * Constructor. |
||
42 | * |
||
43 | * @param \stdClass $structure Data structure from JSON decode |
||
44 | * @throws \coding_exception If invalid data structure. |
||
45 | */ |
||
46 | public function __construct($structure) { |
||
49 | |||
50 | /** |
||
51 | * Create object to be saved representing this condition. |
||
52 | */ |
||
53 | public function save() { |
||
56 | |||
57 | /** |
||
58 | * Returns a JSON object which corresponds to a condition of this type. |
||
59 | * |
||
60 | * Intended for unit testing, as normally the JSON values are constructed |
||
61 | * by JavaScript code. |
||
62 | * |
||
63 | * @param int $viewslimit The limit of views for users |
||
64 | * @return stdClass Object representing condition |
||
65 | */ |
||
66 | public static function get_json($viewslimit = 5) { |
||
69 | |||
70 | /** |
||
71 | * Determines whether a particular item is currently available |
||
72 | * according to this availability condition. |
||
73 | * |
||
74 | * @param bool $not Set true if we are inverting the condition |
||
75 | * @param info $info Item we're checking |
||
76 | * @param bool $grabthelot Performance hint: if true, caches information |
||
77 | * required for all course-modules, to make the front page and similar |
||
78 | * pages work more quickly (works only for current user) |
||
79 | * @param int $userid User ID to check availability for |
||
80 | * @return bool True if available |
||
81 | */ |
||
82 | public function is_available($not, \core_availability\info $info, $grabthelot, $userid) { |
||
98 | |||
99 | /** |
||
100 | * Obtains a string describing this restriction (whether or not |
||
101 | * it actually applies). |
||
102 | * |
||
103 | * @param bool $full Set true if this is the 'full information' view |
||
104 | * @param bool $not Set true if we are inverting the condition |
||
105 | * @param info $info Item we're checking |
||
106 | * @return string Information string (for admin) about all restrictions on |
||
107 | * this item |
||
108 | */ |
||
109 | public function get_description($full, $not, \core_availability\info $info) { |
||
132 | |||
133 | /** |
||
134 | * Obtains a representation of the options of this condition as a string, |
||
135 | * for debugging. |
||
136 | * |
||
137 | * @return string Text representation of parameters |
||
138 | */ |
||
139 | protected function get_debug_string() { |
||
142 | } |
||
143 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.