title: Static method get - is this bad practice?
body: <p>Had a discussion with a colleague about wether this is bad practice or not. Now I can not find immediate examples of this online. </p>
  
  <p>We have a lot of database object mappers and call it's functions like so</p>
  
  <p>(example) - the setId method get's the row from the database and set's it to predefined propertys</p>
  
  <pre><code>class Person {
  
      public static function get($id) {
          $object = new Person;
          $object-&gt;setId($id);
          return $object;
      }
  }
  </code></pre>
  
  <p>Using it like this we can use simple constructions like this: (where we got the id from for-example a post)</p>
  
  <pre><code>$person = Person::get($id);
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>$person = new Person;
  $person-&gt;setId($id);
  </code></pre>
  
  <p>Now, my instinct tells me this is bad practice. But I can not explain it. Maybe someone here can explain why this is, or is not bad practice</p>
  
  <p>Here are some other examples how we use it. we mainly use it for getters. (just the names, not the code. Almost all of them just run a query, which can return 1 object and then use the id of the result to use the setId method)</p>
  
  <pre><code>class CatalogArticle {
     public static function get($id) { }
     public static function getByArticlenumber($articlenumber) {} //$articlenumber is unique in the database
     public static function getRandom() {} //Runs a query returning a random row
  }
  </code></pre>