Start
This commit is contained in:
29
src/Format.php
Normal file
29
src/Format.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza;
|
||||
|
||||
class Format {
|
||||
|
||||
private function __construct(){}
|
||||
|
||||
public static function format_for_select2( array $elem_array, string $id_name, string $text_name ) : array {
|
||||
|
||||
$formatted_array = [];
|
||||
|
||||
foreach ($elem_array as $elem) {
|
||||
if( property_exists( $elem, $id_name ) ) {
|
||||
$formatted_array[] = ['id' => $elem->{$id_name}, 'text' => $elem->{$text_name} ?? "None" ];
|
||||
}
|
||||
}
|
||||
|
||||
return $formatted_array;
|
||||
|
||||
}
|
||||
|
||||
public static function format_nonce_name( string $action ){
|
||||
|
||||
return 'romhackplaza_' . $_ENV['ROMHACKPLAZA_NONCE_KEY'] . '_' . $action;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user