Skip to content

Commit 1700b45

Browse files
Merge pull request #123 from laravelwebdev/add-docstrings
Add docstrings to methods in App/Helpers
2 parents 371cfec + e031bfa commit 1700b45

File tree

4 files changed

+86
-13
lines changed

4 files changed

+86
-13
lines changed

app/Helpers/Api.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
class Api
99
{
10+
/**
11+
* Get unresolved issues from Sentry.
12+
*
13+
* @return array
14+
*/
1015
public static function getSentryUnresolvedIssues()
1116
{
1217
$organization = config('app.sentry_organization');
@@ -30,6 +35,12 @@ public static function getSentryUnresolvedIssues()
3035
}
3136
}
3237

38+
/**
39+
* Get outdated packages from Composer.
40+
*
41+
* @param string $flag
42+
* @return array
43+
*/
3344
public static function getComposerOutdatedPackages($flag = '--no-dev')
3445
{
3546
$composer = config('app.composer');

app/Helpers/Cetak.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@
3030
class Cetak
3131
{
3232
/**
33-
* Cetak Dokumen.
33+
* Print a document.
3434
*
35-
* @param string $jenis kak|spj|sk|st|dpr|spd|bon
36-
* @param collection $model
37-
* @param string $filename
38-
* @return string
35+
* @param string $jenis The type of document (kak|spj|sk|st|dpr|spd|bon)
36+
* @param collection $model The model collection
37+
* @param string $filename The filename for the document
38+
* @param int $template_id The template ID
39+
* @param string|null $tanggal The date (optional)
40+
* @param string|null $pengelola The manager (optional)
41+
* @return string The filename of the saved document
42+
* @throws \Exception
3943
*/
4044
public static function cetak($jenis, $models, $filename, $template_id, $tanggal = null, $pengelola = null)
4145
{
@@ -65,9 +69,13 @@ public static function cetak($jenis, $models, $filename, $template_id, $tanggal
6569
}
6670

6771
/**
68-
* Ambil TemplateProsessor.
72+
* Get the TemplateProcessor.
6973
*
70-
* @param string $jenis kak|spj|sk|st|dpr|spd|bon
74+
* @param string $jenis The type of document (kak|spj|sk|st|dpr|spd|bon)
75+
* @param int $id The ID of the model
76+
* @param int $template_id The template ID
77+
* @param string|null $tanggal The date (optional)
78+
* @param string|null $pengelola The manager (optional)
7179
* @return TemplateProcessor
7280
*/
7381
public static function getTemplate(string $jenis, $id, $template_id, $tanggal, $pengelola)
@@ -169,7 +177,7 @@ public static function getTemplate(string $jenis, $id, $template_id, $tanggal, $
169177
}
170178

171179
/**
172-
* Ambil XML dari dokumen utama.
180+
* Get the XML from the main document.
173181
*
174182
* @param TemplateProcessor $templateProcessor
175183
* @return string
@@ -180,7 +188,7 @@ public static function getMainXml($templateProcessor)
180188
}
181189

182190
/**
183-
* Ambil XML dari dokumen yangakan digabung.
191+
* Get the XML from the document to be merged.
184192
*
185193
* @param TemplateProcessor $templateProcessor
186194
* @return string
@@ -195,9 +203,9 @@ public static function getModifiedInnerXml($templateProcessor)
195203
}
196204

197205
/**
198-
* Format nilai KAK.
206+
* Format the KAK values.
199207
*
200-
* @param string $id
208+
* @param string $id The ID of the KAK
201209
* @return array
202210
*/
203211
public static function kak($id)
@@ -409,9 +417,9 @@ public static function kuitansi($id)
409417
}
410418

411419
/**
412-
* Format nilai SPJ.
420+
* Format the SPJ values.
413421
*
414-
* @param string $id
422+
* @param string $id The ID of the SPJ
415423
* @return array
416424
*/
417425
public static function spj($id)

app/Helpers/Fonnte.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ public function __construct()
2626
$this->account_token = config('fonnte.token');
2727
}
2828

29+
/**
30+
* Make a request to the Fonnte API.
31+
*
32+
* @param string $endpoint The API endpoint to call.
33+
* @param array $params The parameters to send with the request.
34+
* @return array The response from the API.
35+
*/
2936
protected function makeRequest($endpoint, $params = [])
3037
{
3138
$token = $this->account_token;
@@ -53,6 +60,13 @@ protected function makeRequest($endpoint, $params = [])
5360
];
5461
}
5562

63+
/**
64+
* Send a WhatsApp message using the Fonnte API.
65+
*
66+
* @param string $phoneNumber The phone number to send the message to.
67+
* @param string $message The message to send.
68+
* @return array The response from the API.
69+
*/
5670
public function sendWhatsAppMessage($phoneNumber, $message)
5771
{
5872
return $this->makeRequest(self::ENDPOINTS['send_message'], [
@@ -61,11 +75,21 @@ public function sendWhatsAppMessage($phoneNumber, $message)
6175
]);
6276
}
6377

78+
/**
79+
* Update the WhatsApp group list using the Fonnte API.
80+
*
81+
* @return array The response from the API.
82+
*/
6483
public function updateWhatsappGroupList()
6584
{
6685
return $this->makeRequest(self::ENDPOINTS['update_group']);
6786
}
6887

88+
/**
89+
* Get the WhatsApp group list using the Fonnte API.
90+
*
91+
* @return array The response from the API.
92+
*/
6993
public function getWhatsappGroupList()
7094
{
7195
return $this->makeRequest(self::ENDPOINTS['list_group']);

app/Helpers/Helper.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ class Helper
259259
'IV/e' => 15,
260260
];
261261

262+
/**
263+
* Get the name of the last sheet in an Excel file.
264+
*
265+
* @param string $file The path to the Excel file.
266+
* @return string The name of the last sheet.
267+
*/
262268
public static function getLastSheetName($file)
263269
{
264270
$reader = new Reader;
@@ -271,6 +277,12 @@ public static function getLastSheetName($file)
271277
return $name;
272278
}
273279

280+
/**
281+
* Format a phone number to a WhatsApp URL.
282+
*
283+
* @param string $telepon The phone number to format.
284+
* @return string The formatted WhatsApp URL.
285+
*/
274286
public static function formatTelepon($telepon)
275287
{
276288
$wa = str_replace('+62 08', '628', $telepon);
@@ -280,6 +292,12 @@ public static function formatTelepon($telepon)
280292
return "https://wa.me/{$wa}";
281293
}
282294

295+
/**
296+
* Check if the current date is within a specific quarter.
297+
*
298+
* @param int $tw The quarter to check (1, 2, 3, or 4).
299+
* @return bool True if the current date is within the specified quarter, false otherwise.
300+
*/
283301
public static function is_triwulan($tw)
284302
{
285303
$now = Carbon::now();
@@ -297,6 +315,12 @@ public static function is_triwulan($tw)
297315
}
298316
}
299317

318+
/**
319+
* Check if the current date is within a specific cumulative quarter.
320+
*
321+
* @param int $tw The cumulative quarter to check (1, 2, 3, or 4).
322+
* @return bool True if the current date is within the specified cumulative quarter, false otherwise.
323+
*/
300324
public static function is_triwulan_kumulatif($tw)
301325
{
302326
$now = Carbon::now();
@@ -314,6 +338,12 @@ public static function is_triwulan_kumulatif($tw)
314338
}
315339
}
316340

341+
/**
342+
* Get the current quarter based on the given month.
343+
*
344+
* @param int $month The month to determine the quarter.
345+
* @return int The current quarter (1, 2, 3, or 4).
346+
*/
317347
public static function getTriwulanBerjalan($month)
318348
{
319349
return (int) ceil($month / 3);

0 commit comments

Comments
 (0)