public function __construct(Config $config = null) { if (!$config) { $config = new Config(); } $this->data = $config->getData(); $this->cityAddress = new CityAddress($this->data); $this->warehouseAddress = new WarehouseAddress($this->data); }
public function getData() { if (file_exists($this->file->address)) { $days = (time() - filectime($this->file->address)) / 86400; if ($days > self::DAYS_UPDATE_FILE) { $this->file->delete(); return $this->getData(); } $data = file_get_contents($this->file->address); $data = unserialize($data); } else { $data = parent::getData(); file_put_contents($this->file->address, serialize($data), LOCK_EX); } return $data; }