toInt를 더 튼튼하게 개선. ROOT가 지정되었으므로 강제 지정하는 코드 해제
This commit is contained in:
+8
-2
@@ -42,7 +42,10 @@ class Util extends \utilphp\util{
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public static function toInt($val, $force=false){
|
||||
public static function toInt($val, $silent=false){
|
||||
if(!isset($val)){
|
||||
return null;
|
||||
}
|
||||
if($val === null){
|
||||
return null;
|
||||
}
|
||||
@@ -56,7 +59,10 @@ class Util extends \utilphp\util{
|
||||
return null;
|
||||
}
|
||||
|
||||
if($force){
|
||||
if($silent){
|
||||
if($val == null){
|
||||
return null;
|
||||
}
|
||||
return intval($val);
|
||||
}
|
||||
throw new InvalidArgumentException('올바르지 않은 타입형 :'.$val);
|
||||
|
||||
Reference in New Issue
Block a user