title: Modeling a M-N Relationship in OOP
body: <p>This is the closest thing I could find to my problem on <a href="https://stackoverflow.com/questions/10233722/class-association">here</a></p>
  
  <p>I'm working on a projects and I want to add a security model to it, so since I have experience first hand how bad jumping into coding and skipping the planning phase is I decided to do that first.  So I created an ERD, cool do it all the time, then the UML Class diagram, haven't done one of these since college, ok a little bit of google, go it.</p>
  
  <p>See ERD And UML Class Diagram <a href="http://i1243.photobucket.com/albums/gg559/419josh/Erd-Uml_zpse69327aa.png" rel="nofollow noreferrer">Here</a></p>
  
  <p>The image above is an exert of what I have so far, I know that I certainly need a User Class and a Permission Class but I'm not sure how to handle the relationship between the two. I know generally in an M-N relationship you model it with a property that is a collection of the related class but what about the properties of the related class? Below is my best guess, if anyone has corrections, comments, or links to material to read that would be awesome. My goal is the proper implementation of OOP thanks in advance.</p>
  
  <pre><code>class User{
      private $id;
      private $password;
      private $active;
      private $permissions;
      /* skip getters and setters */
  
      function getUserPermissions(){
          return UserPermission[];
      }
  
  }
  
  class UserPermission{
      private $id;
      private $deny;
      private $grant;
      private $active;
      /* skip getters and setters */
  
       function getPermissions(){
          return Permission[];
       }
  }
  
  class Permission{
      private $id;
      private $name;
      private $description;
      private $active;
  
      /* skip getters and setters */      
  }
  </code></pre>