* php オブジェクト指向コーディングでこのタイプの問題を処理する方法に関する問題/混乱 *
顧客のサービスを一時停止する必要がある顧客クラスがありますが、顧客がサービスの保留中の作業タイプを持っている場合、呼び出し元の関数がエラー処理を行うために false を返す必要があります (ここではできません。電子メール、出力、または html)
ただし、次のコードを使用するかのようにこれを処理する方法が混乱しています foreach ループの最後の条件でのみ false を返します
/**
* return false on failier
* Customer suspend all services for this customer
*
*/
public function suspendServices(){
$pending=false;
foreach ($this->services() as $service) {
$pending = $service->hasPendingWorktypes();
if($pending === true) {
return false;
}
$service->state()->changeTo(8);
}//end of foreach services
}//end of function