toInt에 강제 변환 기능 추가(=intval에 null만 추가)
This commit is contained in:
+7
-1
@@ -207,7 +207,7 @@ function PrintElapsedTime() {
|
|||||||
*
|
*
|
||||||
* @return int|null
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
function toInt($val){
|
function toInt($val, $force=false){
|
||||||
if($val === null){
|
if($val === null){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,13 @@ function toInt($val){
|
|||||||
if(is_numeric($val)){
|
if(is_numeric($val)){
|
||||||
return intval($val);//
|
return intval($val);//
|
||||||
}
|
}
|
||||||
|
if($val === 'NULL' || $val === 'null'){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($force){
|
||||||
|
return intval($val);
|
||||||
|
}
|
||||||
throw new InvalidArgumentException('올바르지 않은 타입형 :'.$val);
|
throw new InvalidArgumentException('올바르지 않은 타입형 :'.$val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user