Skip to content

Commit 2fba90b

Browse files
committed
Added comments.
1 parent 4926dc9 commit 2fba90b

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

includes/MultiCodeBlockBuilder.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ function getDOM(&$content) {
2424
return $dom;
2525
}
2626

27+
/**
28+
* Creates an HTML-Element to warp around the content.
29+
*
30+
* @param string $code The code where the Element should wrap around
31+
* @param int $index The index of the element
32+
* @param string $extra Another class to be added to the element.
33+
*
34+
* @return string The full object.
35+
*/
2736
function createTab(string &$code, int $index, string $extra = 'outer') {
2837
return '<div class="'.$extra.' tab-content '.($index == 0 ? 'tc-active' : '').'" data-tab="'.$index.'">'.$code.'</div>';
2938
}
@@ -33,6 +42,8 @@ function createTab(string &$code, int $index, string $extra = 'outer') {
3342
*
3443
* @param array $lang All of the languages of the different codeblocks.
3544
* @param string $code The codeblocks as a whole.
45+
* @param string $extra Another class to be added to the element.
46+
* @param bool $addCopy If a copy button should be added to the element.
3647
*
3748
* @return string The whole MultiCodeBlock.
3849
*/

includes/class/LanguageBlock.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
11
<?php
2+
3+
/**
4+
* Saves the Description and the Code Objects
5+
*
6+
* @global array $code The array of Code Objects
7+
* @global array $desc The array of Description Objects
8+
* @global int $size The size of the $code block.
9+
*
10+
* @param array $codeblocks The codeblocks that should be added to $code
11+
* @param $descriptions The descriptions that should be added to $desc
12+
* @param string $lang The language of the Block
13+
*/
214
class LanguageBlock {
315
public array $code = [];
416
public array $desc = [];
517

618
public int $size = 0;
719
private int $sizeDescription = 0;
820

9-
public function __construct(array &$codeblocks = null, &$descriptions = null, &$lang = null) {
21+
public function __construct(array &$codeblocks = null, &$descriptions = null, string &$lang = null) {
1022
if($codeblocks === null || $descriptions === null || $lang === null)
1123
return;
1224

1325
$this->setLanguageBlock($codeblocks, $descriptions, $lang);
1426
}
1527

16-
public function setLanguageBlock(array &$codeblocks, &$descriptions, &$lang) {
28+
/**
29+
* Saves the Description and the Code Objects in the attributes.
30+
*
31+
* @param array $codeblocks The codeblocks that should be added to $code
32+
* @param $descriptions The descriptions that should be added to $desc
33+
* @param string $lang The language of the Block
34+
*/
35+
public function setLanguageBlock(array &$codeblocks, &$descriptions, string &$lang) {
1736
$sizeCode = 0;
1837

1938
foreach($codeblocks as $code) {
@@ -31,6 +50,14 @@ public function setLanguageBlock(array &$codeblocks, &$descriptions, &$lang) {
3150
$this->sizeDescription = $sizeDesc;
3251
}
3352

53+
/**
54+
* Returns the Description Object based on the index.
55+
* When $index is larger then the size of $desc a new Description object will be returned.
56+
*
57+
* @param int $index The index of the requested Description Object
58+
*
59+
* @return Description The Object from the location or a new Description object.
60+
*/
3461
public function &getDescription(int $index) {
3562
if($this->sizeDescription < ($index + 1)) {
3663
$descr = new Description();

0 commit comments

Comments
 (0)