title: Avoiding to instantiate an object with invalid argument
body: <p>I'm currently developing a little private project in order to get more acquainted with PHP and OOP in general. Basically, I am creating a little app that is able to create posts and tag them. </p>
  
  <p>The classes are organised like this so far:</p>
  
  <ul>
  <li><p><strong>Post</strong><br>
  Represents a post in the database, and has functions such as <code>editPost()</code>, <code>attachTag()</code>, etc.</p></li>
  <li><p><strong>Tag</strong><br>
  Represents a tag in the database, and similarly, has functions such as <code>editTag()</code>, etc.</p></li>
  <li><p><strong>PostUtils</strong><br>
  This is like a management interface, it is used to create/delete new posts and tags, list 
  them, etc. </p></li>
  </ul>
  
  <p>Now, when I instantiate a new Post object, I do so by passing the post ID as its required argument. When I do that, I would like to be able to check first whether the ID is valid or not. So far I've been doing that by using a method in the PostUtils class (<code>isValidID($id)</code>), so that the controller can perform a check before the Post class is instantiated. However, I've been reading about the <a href="http://pragprog.com/articles/tell-dont-ask" rel="nofollow">Tell, Don't Ask</a> principle, and it seems to me that I should perform this check within the Post class itself instead. </p>
  
  <p>Ideally, I would like the object to be instantiated only when a valid ID is passed. So my question is, what would be the best behaviour for the class when a non-valid ID is passed instead? Does this make sense at all? Or does my whole architecture need to be changed to start with? </p>
  
  <p>Thank you very much for your time, it is really appreciated :)</p>