Skip to content

Commit e510198

Browse files
committed
codecleaning
1 parent a502e8d commit e510198

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

lib.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
* @param int|null $courseid
9393
* @param int|null $gradecatid
9494
* @return int|null
95+
* @throws dml_exception
9596
*/
9697
function moodleoverflow_validate_grade_category(?int $courseid, ?int $gradecatid): ?int {
9798
global $DB;
@@ -114,27 +115,18 @@ function moodleoverflow_validate_grade_category(?int $courseid, ?int $gradecatid
114115
*
115116
* @return mixed true if the feature is supported, null if unknown
116117
*/
117-
function moodleoverflow_supports($feature) {
118+
function moodleoverflow_supports(string $feature): mixed {
118119

119120
if (defined('FEATURE_MOD_PURPOSE')) {
120121
if ($feature == FEATURE_MOD_PURPOSE) {
121122
return MOD_PURPOSE_COLLABORATION;
122123
}
123124
}
124125

125-
switch ($feature) {
126-
case FEATURE_MOD_INTRO:
127-
return true;
128-
case FEATURE_SHOW_DESCRIPTION:
129-
return true;
130-
case FEATURE_BACKUP_MOODLE2:
131-
return true;
132-
case FEATURE_GRADE_HAS_GRADE:
133-
return true;
134-
135-
default:
136-
return null;
137-
}
126+
return match ($feature) {
127+
FEATURE_MOD_INTRO, FEATURE_SHOW_DESCRIPTION, FEATURE_BACKUP_MOODLE2, FEATURE_GRADE_HAS_GRADE => true,
128+
default => null,
129+
};
138130
}
139131

140132
/**
@@ -150,7 +142,7 @@ function moodleoverflow_supports($feature) {
150142
*
151143
* @return int The id of the newly inserted moodleoverflow record
152144
*/
153-
function moodleoverflow_add_instance(stdClass $moodleoverflow, ?mod_moodleoverflow_mod_form $mform = null) {
145+
function moodleoverflow_add_instance(stdClass $moodleoverflow, ?mod_moodleoverflow_mod_form $mform = null): int {
154146
global $DB;
155147

156148
// Set the current time.
@@ -174,7 +166,7 @@ function moodleoverflow_add_instance(stdClass $moodleoverflow, ?mod_moodleoverfl
174166
* Handle changes following the creation of a moodleoverflow instance.
175167
* This function is typically called by the course_module_created observer.
176168
*
177-
* @param object $context The context of the moodleoverflow
169+
* @param context_module $context The context of the moodleoverflow
178170
* @param stdClass $moodleoverflow The moodleoverflow object
179171
*/
180172
function moodleoverflow_instance_created(context_module $context, $moodleoverflow) {

0 commit comments

Comments
 (0)