Checking if a relationship exists
You don't have to loop throught the collection since you can directly query the database or your object if it is already loaded:

class User extends BaseUser
{       
    public function hasRole($checkRole)
    {
        $userWithRole = UserQuery::create()
            -&gt;filterByRole($checkRole)
            -&gt;findOne();

        return !is_null($userWithRole);
    }
}


You can either check that $userWithRole is not null like I did or if it is an instance of User.

If your objects are already hydrated you can avoid the query by querying the Roles collection:

class User extends BaseUser
{       
    public function hasRole($checkRole)
    {
        return $this-&gt;getRoles()-&gt;contains($checkRole);
    }
}