What pattern is this? php
- by user151841
I have several classes that are basically interfaces to database rows. Since the class assumes that a row already exists ( __construct expects a field value ), there is a public static function that allows creation of the row and returns an instance of the class.
Here's an example ( without the actual database inserts ):
class selfStarter {
public $type;
public function __construct( $type ) {
$this->type = $type;
}
public static function create( $type ) {
if ( ! empty($type) ) {
$starter = & new selfStarter($type);
return $starter;
}
}
}
$obj1 = selfStarter::create( "apple" );
$obj2 = & new selfStarter( "banana" );
What is this pattern called?