Skip to content

Commit d7c5636

Browse files
committed
fix codesniffer issues and improve php comments
1 parent 9d78833 commit d7c5636

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

classes/snippets.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public static function get_snippet_scss($path, $source) {
9696
* Get a snippet defined in the code based on path.
9797
*
9898
* @param string $path
99+
* @param string $source
99100
*
100101
* @return mixed
101102
*/
@@ -105,16 +106,20 @@ public static function get_snippet_meta($path, $source) {
105106
// Get the snippets file, based on the source.
106107
$file = self::get_snippet_file($path, $source);
107108

109+
// If the file does not exist or is not readable, we can not proceed.
108110
if (is_null($file)) {
109-
return;
111+
return null;
110112
}
111113

114+
// Extract the meta from the SCSS files top level multiline comment in WordPress style.
112115
$headers = self::get_snippet_meta_from_file($file);
113116

117+
// The title is the only required meta-key that actually must be set.
114118
if (!array_key_exists('Snippet Title', $headers)) {
115119
return null;
116120
}
117121

122+
// Create an object containing the information.
118123
$snippet = new \stdClass();
119124
$snippet->title = $headers['Snippet Title'];
120125
$snippet->description = $headers['Description'];
@@ -126,18 +131,23 @@ public static function get_snippet_meta($path, $source) {
126131
}
127132

128133
/**
129-
* Compose snippets file data to record.
134+
* Combine snippets meta data from the snippets file with the database record.
135+
*
136+
* This is currently used for create the view for the settings table.
130137
*
131-
* @param mixed $data
138+
* @param moodle_recordset $snippetrecordset
132139
*
133140
* @return array
134141
*/
135142
public static function compose_snippets_data($snippetrecordset) {
136143
$snippets = [];
137144

138145
foreach ($snippetrecordset as $snippetrecord) {
146+
// Get the meta information from the SCSS files top multiline comment.
139147
$snippet = self::get_snippet_meta($snippetrecord->path, $snippetrecord->source);
148+
// If snippets meta is not found, it will no be added to the returned snippet array.
140149
if ($snippet) {
150+
// Merge the two objects.
141151
$snippets[] = (object) array_merge((array) $snippetrecord, (array) $snippet);
142152
}
143153
}

0 commit comments

Comments
 (0)