public function getContact($id)
    {
        //get contact from db
        foreach ($this->contacts as $contact) {
            if ($contact->id == $id) {
                return $contact;
            }
        }
        //might wanna throw an exception when it does not exists
        throw new Exception("Contact '$id' not found");
    }
public function getContact($id)
    {
        //get contact from db
        foreach ($this->contacts as $contact) {
            if ($contact->id == $id) {
                return $contact;
            }
        }
        //might wanna throw an exception when it does not exists
        throw new Exception("Contact '$id' not found");
    }
public function getContact ( $ id ) { //get contact from db foreach ( $ this -> contacts as $ contact ) { if ( $ contact -> id == $ id ) { return $ contact ; } } //might wanna throw an exception when it does not exists throw new Exception ( "Contact '$id' not found" ) ; }
Gets the contact with the given id.

@param int The id

@return contact
Gets the contact with the given id .