php - replace die to stop process -
i'm using die stop process when error:
main class:
class myclass { public function mymethod () { $helper->checkparameter( $thisparametercannotbeempty ); } }
and helper
class control { public function checkparameter ( $param ) { if ( $param == "" ) { echo "parameter can not empty"; die; } } }
like if parameter empty have error message , process stopped.
but problem want use unit tests (with phpunit) , die stop process (ok) , unit tests execution (not ok).
with zend 1.12, possible stop process calling view or instead of kill php process ?
thx
like @leggendario said, use must use exceptions.
class control { public function checkparameter ( $param ) { if ( $param == "" ) { throw new \exception("parameter can not empty"); } } }
the \
before exception
tells php use built in namespace exception.
Comments
Post a Comment