toInt에 강제 변환 기능 추가(=intval에 null만 추가)

This commit is contained in:
2018-02-04 04:33:25 +09:00
parent 2708b48bd9
commit e42643d439
+7 -1
View File
@@ -207,7 +207,7 @@ function PrintElapsedTime() {
*
* @return int|null
*/
function toInt($val){
function toInt($val, $force=false){
if($val === null){
return null;
}
@@ -217,7 +217,13 @@ function toInt($val){
if(is_numeric($val)){
return intval($val);//
}
if($val === 'NULL' || $val === 'null'){
return null;
}
if($force){
return intval($val);
}
throw new InvalidArgumentException('올바르지 않은 타입형 :'.$val);
}