I m trying to undestand how FuelPHP was written.. And since I don t know OOP much, I m puzzled when this class: https://github.com/fuel/core/blob/master/classes/date.php
Here are methods that I don t understand:
public static function _init()
{
static::$server_gmt_offset = Config::get( server_gmt_offset , 0);
// some code here
}
public static function factory($timestamp = null, $timezone = null)
{
$timestamp = is_null($timestamp) ? time() + static::$server_gmt_offset : $timestamp;
$timezone = is_null($timezone) ? Fuel::$timezone : $timezone;
return new static($timestamp, $timezone);
}
protected function __construct($timestamp, $timezone)
{
$this->timestamp = $timestamp;
$this->set_timezone($timezone);
}
What is called first? What __counctruct does? What is factory, when it s used, what it returns - does it call itself again? Is _init called after initializing class? I m really puzzled, can someone help me understand? Thanks