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+ */
214class 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