Cast the required field properly and add helper #146

This commit is contained in:
Nabeel Shahzad
2018-01-21 13:43:32 -05:00
parent e86fd64235
commit f09b3b888a
3 changed files with 29 additions and 11 deletions

View File

@@ -1,5 +1,25 @@
<?php
if(!function_exists('get_truth_state')) {
/**
* Check if the passed state matches any of the states that
* we regard as being true or false
* @param $state
* @return bool
*/
function get_truth_state($state)
{
$enabledStates = [
'on',
'true',
'1',
true,
];
return \in_array($state, $enabledStates, false);
}
}
if(!function_exists('list_to_assoc')) {
/**
* Converts a straight list into an assoc array with