php - what's the purpose of factories? -
i'm trying understand why object should created using factories , not new
operator? example:
$validatepost = validation::factory($_post);
instead of
$validatepost = new validation($_post);
the static method factory
of class same:
public static function factory(array $array) { return new validation($array); }
this way have 1 method objects created with. , if need add additional functionality creating, example, models, override original factory() method own in application folder.
Comments
Post a Comment