Wait with getting the timezone from the server until we need it

This commit is contained in:
Robin Appelman 2015-03-13 13:12:00 +01:00
commit 476980d4ce
5 changed files with 72 additions and 15 deletions

35
src/TimeZoneProvider.php Normal file
View file

@ -0,0 +1,35 @@
<?php
/**
* Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB;
class TimeZoneProvider {
/**
* @var string
*/
private $host;
/**
* @var string
*/
private $timeZone;
/**
* @param string $host
*/
function __construct($host) {
$this->host = $host;
}
public function get() {
if (!$this->timeZone) {
$command = 'net time zone -S ' . escapeshellarg($this->host);
$this->timeZone = exec($command);
}
return $this->timeZone;
}
}