PHP Function error handling and returning when foreach loop goes on a variable
<p>*<strong><em>problem/confusion on how to handle this type problem in the php object oriented coding *</em></strong> </p>

<p>I have customer class which i need to suspend services for customers, however when the customer has pending work types for a service, i need to return a false for the calling function to do the error handle (i cant do it here becos it could be a email,output, or html) </p>

<p>however i am confused how to handle this as if use following code it will return false only on the last condition on the foreach loop i guess, any idea on how to handle this in the coding point of view</p>

<pre><code> /**
   * return false on failier 
   * Customer suspend all services for this customer
   * 
   */
  public function suspendServices(){

    $pending=false; 

    foreach ($this-&gt;services() as $service) {

    $pending = $service-&gt;hasPendingWorktypes();

    if($pending === true) {
        return false;
    }   
    $service-&gt;state()-&gt;changeTo(8);  

    }//end of foreach services 

  }//end of function
</code></pre>
