Conditions | 2 |
Paths | 2 |
Total Lines | 61 |
Code Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
90 | private function createGlossaryXml(array $glossaryData, string $glossaryDir): void |
||
91 | { |
||
92 | $xml = '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL; |
||
93 | $xml .= '<activity id="'.$glossaryData['id'].'" moduleid="'.$glossaryData['moduleid'].'" modulename="'.$glossaryData['modulename'].'" contextid="'.$glossaryData['contextid'].'">'.PHP_EOL; |
||
94 | $xml .= ' <glossary id="'.$glossaryData['id'].'">'.PHP_EOL; |
||
95 | $xml .= ' <name>'.htmlspecialchars((string) $glossaryData['name']).'</name>'.PHP_EOL; |
||
96 | $xml .= ' <intro></intro>'.PHP_EOL; |
||
97 | $xml .= ' <introformat>1</introformat>'.PHP_EOL; |
||
98 | $xml .= ' <allowduplicatedentries>0</allowduplicatedentries>'.PHP_EOL; |
||
99 | $xml .= ' <displayformat>dictionary</displayformat>'.PHP_EOL; |
||
100 | $xml .= ' <mainglossary>0</mainglossary>'.PHP_EOL; |
||
101 | $xml .= ' <showspecial>1</showspecial>'.PHP_EOL; |
||
102 | $xml .= ' <showalphabet>1</showalphabet>'.PHP_EOL; |
||
103 | $xml .= ' <showall>1</showall>'.PHP_EOL; |
||
104 | $xml .= ' <allowcomments>0</allowcomments>'.PHP_EOL; |
||
105 | $xml .= ' <allowprintview>1</allowprintview>'.PHP_EOL; |
||
106 | $xml .= ' <usedynalink>1</usedynalink>'.PHP_EOL; |
||
107 | $xml .= ' <defaultapproval>1</defaultapproval>'.PHP_EOL; |
||
108 | $xml .= ' <globalglossary>0</globalglossary>'.PHP_EOL; |
||
109 | $xml .= ' <entbypage>10</entbypage>'.PHP_EOL; |
||
110 | $xml .= ' <editalways>0</editalways>'.PHP_EOL; |
||
111 | $xml .= ' <rsstype>0</rsstype>'.PHP_EOL; |
||
112 | $xml .= ' <rssarticles>0</rssarticles>'.PHP_EOL; |
||
113 | $xml .= ' <assessed>0</assessed>'.PHP_EOL; |
||
114 | $xml .= ' <assesstimestart>0</assesstimestart>'.PHP_EOL; |
||
115 | $xml .= ' <assesstimefinish>0</assesstimefinish>'.PHP_EOL; |
||
116 | $xml .= ' <scale>100</scale>'.PHP_EOL; |
||
117 | $xml .= ' <timecreated>'.$glossaryData['timecreated'].'</timecreated>'.PHP_EOL; |
||
118 | $xml .= ' <timemodified>'.$glossaryData['timemodified'].'</timemodified>'.PHP_EOL; |
||
119 | $xml .= ' <completionentries>0</completionentries>'.PHP_EOL; |
||
120 | |||
121 | // Entries |
||
122 | $xml .= ' <entries>'.PHP_EOL; |
||
123 | foreach ($glossaryData['entries'] as $entry) { |
||
124 | $xml .= ' <entry id="'.$entry['id'].'">'.PHP_EOL; |
||
125 | $xml .= ' <userid>'.$entry['userid'].'</userid>'.PHP_EOL; |
||
126 | $xml .= ' <concept>'.htmlspecialchars((string) $entry['concept']).'</concept>'.PHP_EOL; |
||
127 | $xml .= ' <definition><![CDATA['.$entry['definition'].']]></definition>'.PHP_EOL; |
||
128 | $xml .= ' <definitionformat>1</definitionformat>'.PHP_EOL; |
||
129 | $xml .= ' <definitiontrust>0</definitiontrust>'.PHP_EOL; |
||
130 | $xml .= ' <attachment></attachment>'.PHP_EOL; |
||
131 | $xml .= ' <timecreated>'.$entry['timecreated'].'</timecreated>'.PHP_EOL; |
||
132 | $xml .= ' <timemodified>'.$entry['timemodified'].'</timemodified>'.PHP_EOL; |
||
133 | $xml .= ' <teacherentry>1</teacherentry>'.PHP_EOL; |
||
134 | $xml .= ' <sourceglossaryid>0</sourceglossaryid>'.PHP_EOL; |
||
135 | $xml .= ' <usedynalink>0</usedynalink>'.PHP_EOL; |
||
136 | $xml .= ' <casesensitive>0</casesensitive>'.PHP_EOL; |
||
137 | $xml .= ' <fullmatch>0</fullmatch>'.PHP_EOL; |
||
138 | $xml .= ' <approved>1</approved>'.PHP_EOL; |
||
139 | $xml .= ' <ratings>'.PHP_EOL; |
||
140 | $xml .= ' </ratings>'.PHP_EOL; |
||
141 | $xml .= ' </entry>'.PHP_EOL; |
||
142 | } |
||
143 | $xml .= ' </entries>'.PHP_EOL; |
||
144 | |||
145 | $xml .= ' <entriestags></entriestags>'.PHP_EOL; |
||
146 | $xml .= ' <categories></categories>'.PHP_EOL; |
||
147 | $xml .= ' </glossary>'.PHP_EOL; |
||
148 | $xml .= '</activity>'; |
||
149 | |||
150 | $this->createXmlFile('glossary', $xml, $glossaryDir); |
||
151 | } |
||
153 |