Revert "refactor: remove Hungarian notation and MCI prefixes"

This reverts commit 1284544556.
This commit is contained in:
Ben Goldsworthy 2021-04-19 12:15:17 +01:00
parent c0672461b0
commit 2f809f4fe9
15 changed files with 1710 additions and 1710 deletions

View file

@ -14,34 +14,34 @@
*
* @since 1.5.0
*/
class Footnotes_Convert {
class MCI_Footnotes_Convert {
/**
* Converts a integer into the user-defined counter style for the footnotes.
*
* @since 1.5.0
* @param int $index Index to be converted.
* @param string $convert_style Style of the new/converted Index.
* @param int $p_int_index Index to be converted.
* @param string $p_str_convert_style Style of the new/converted Index.
* @return string Converted Index as string in the defined counter style.
*
* Edited:
* @since 2.2.0 lowercase Roman numerals supported
*/
public static function index( $index, $convert_style = 'arabic_plain' ) {
switch ( $convert_style ) {
public static function index( $p_int_index, $p_str_convert_style = 'arabic_plain' ) {
switch ( $p_str_convert_style ) {
case 'romanic':
return self::to_romanic( $index, true );
return self::to_romanic( $p_int_index, true );
case 'roman_low':
return self::to_romanic( $index, false );
return self::to_romanic( $p_int_index, false );
case 'latin_high':
return self::to_latin( $index, true );
return self::to_latin( $p_int_index, true );
case 'latin_low':
return self::to_latin( $index, false );
return self::to_latin( $p_int_index, false );
case 'arabic_leading':
return self::to_arabic_leading( $index );
return self::to_arabic_leading( $p_int_index );
case 'arabic_plain':
default:
return $index;
return $p_int_index;
}
}
@ -50,62 +50,62 @@ class Footnotes_Convert {
* Function available from A to ZZ ( means 676 footnotes at 1 page possible).
*
* @since 1.0-gamma
* @param int $value Value/Index to be converted.
* @param bool $upper_case True to convert the value to upper case letter, otherwise to lower case.
* @param int $p_int_value Value/Index to be converted.
* @param bool $p_bool_upper_case True to convert the value to upper case letter, otherwise to lower case.
* @return string
*/
private static function to_latin( $value, $upper_case ) {
private static function to_latin( $p_int_value, $p_bool_upper_case ) {
// Output string.
$return = '';
$offset = 0;
$l_str_return = '';
$l_int_offset = 0;
// Check if the value is higher then 26 = Z.
while ( $value > 26 ) {
while ( $p_int_value > 26 ) {
// Increase offset and reduce counter.
$offset++;
$value -= 26;
$l_int_offset++;
$p_int_value -= 26;
}
// If offset set (more then Z), then add a new letter in front.
if ( $offset > 0 ) {
$return = chr( $offset + 64 );
if ( $l_int_offset > 0 ) {
$l_str_return = chr( $l_int_offset + 64 );
}
// Add the origin letter.
$return .= chr( $value + 64 );
$l_str_return .= chr( $p_int_value + 64 );
// Return the latin character representing the integer.
if ( $upper_case ) {
return strtoupper( $return );
if ( $p_bool_upper_case ) {
return strtoupper( $l_str_return );
}
return strtolower( $return );
return strtolower( $l_str_return );
}
/**
* Converts an integer to a leading-0 integer.
*
* @since 1.0-gamma
* @param int $value Value/Index to be converted.
* @param int $p_int_value Value/Index to be converted.
* @return string Value with a leading zero.
*/
private static function to_arabic_leading( $value ) {
private static function to_arabic_leading( $p_int_value ) {
// Add a leading 0 if number lower then 10.
if ( $value < 10 ) {
return '0' . $value;
if ( $p_int_value < 10 ) {
return '0' . $p_int_value;
}
return $value;
return $p_int_value;
}
/**
* Converts an integer to a romanic letter.
*
* @since 1.0-gamma
* @param int $value Value/Index to be converted.
* @param bool $upper_case Whether to uppercase.
* @param int $p_int_value Value/Index to be converted.
* @param bool $p_bool_upper_case Whether to uppercase.
* @return string
*
* Edited:
* @since 2.2.0 optionally lowercase (code from Latin)
*/
private static function to_romanic( $value, $upper_case ) {
private static function to_romanic( $p_int_value, $p_bool_upper_case ) {
// Table containing all necessary romanic letters.
$romanic_letters = array(
$l_arr_romanic_letters = array(
'M' => 1000,
'CM' => 900,
'D' => 500,
@ -121,36 +121,36 @@ class Footnotes_Convert {
'I' => 1,
);
// Return value.
$return = '';
$l_str_return = '';
// Iterate through integer value until it is reduced to 0.
while ( $value > 0 ) {
foreach ( $romanic_letters as $romanic => $arabic ) {
if ( $value >= $arabic ) {
$value -= $arabic;
$return .= $romanic;
while ( $p_int_value > 0 ) {
foreach ( $l_arr_romanic_letters as $l_str_romanic => $l_int_arabic ) {
if ( $p_int_value >= $l_int_arabic ) {
$p_int_value -= $l_int_arabic;
$l_str_return .= $l_str_romanic;
break;
}
}
}
// Return romanic letters as string.
if ( $upper_case ) {
return strtoupper( $return );
if ( $p_bool_upper_case ) {
return strtoupper( $l_str_return );
}
return strtolower( $return );
return strtolower( $l_str_return );
}
/**
* Converts a string depending on its value to a boolean.
*
* @since 1.0-beta
* @param string $value String to be converted to boolean.
* @param string $p_str_value String to be converted to boolean.
* @return bool Boolean representing the string.
*/
public static function to_bool( $value ) {
public static function to_bool( $p_str_value ) {
// Convert string to lower-case to make it easier.
$value = strtolower( $value );
$p_str_value = strtolower( $p_str_value );
// Check if string seems to contain a "true" value.
switch ( $value ) {
switch ( $p_str_value ) {
case 'checked':
case 'yes':
case 'true':
@ -166,22 +166,22 @@ class Footnotes_Convert {
* Get a html Array short code depending on Arrow-Array key index.
*
* @since 1.3.2
* @param int $index Index representing the Arrow. If empty all Arrows are specified.
* @param int $p_int_index Index representing the Arrow. If empty all Arrows are specified.
* @return array|string Array of all Arrows if Index is empty otherwise html tag of a specific arrow.
*/
public static function get_arrow( $index = -1 ) {
public static function get_arrow( $p_int_index = -1 ) {
// Define all possible arrows.
$arrows = array( '&#8593;', '&#8613;', '&#8607;', '&#8617;', '&#8626;', '&#8629;', '&#8657;', '&#8673;', '&#8679;', '&#65514;' );
$l_arr_arrows = array( '&#8593;', '&#8613;', '&#8607;', '&#8617;', '&#8626;', '&#8629;', '&#8657;', '&#8673;', '&#8679;', '&#65514;' );
// Convert index to an integer.
if ( ! is_int( $index ) ) {
$index = intval( $index );
if ( ! is_int( $p_int_index ) ) {
$p_int_index = intval( $p_int_index );
}
// Return the whole arrow array.
if ( $index < 0 || $index > count( $arrows ) ) {
return $arrows;
if ( $p_int_index < 0 || $p_int_index > count( $l_arr_arrows ) ) {
return $l_arr_arrows;
}
// Return a single arrow.
return $arrows[ $index ];
return $l_arr_arrows[ $p_int_index ];
}
// phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_var_dump