Import/export expenses #194

This commit is contained in:
Nabeel Shahzad
2018-03-22 17:17:37 -05:00
parent 4e3a9fd9ea
commit a44204b185
32 changed files with 613 additions and 139 deletions

View File

@@ -8,8 +8,9 @@ namespace App\Interfaces;
*/
abstract class Enum
{
protected static $labels = [];
protected static $cache = [];
protected static $codes = [];
protected static $labels = [];
/**
* @var integer
@@ -59,6 +60,31 @@ abstract class Enum
return $labels;
}
/**
* Get the numeric value from a string code
* @param $code
* @return mixed|null
*/
public static function getFromCode($code)
{
$code = strtoupper($code);
if(!array_key_exists($code, static::$codes)) {
return null;
}
return static::$codes[$code];
}
/**
* Convert the integer value into one of the codes
* @param $value
* @return false|int|string
*/
public static function convertToCode($value)
{
return array_search($value, static::$codes, true);
}
/**
* Select box entry items
* @param bool $add_blank