@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @var string; |
| 38 | 38 | */ |
| 39 | - const ENDPOINT='https://www.windguru.cz'; |
|
| 40 | - const LOGFOLDER='logs'; |
|
| 41 | - const CACHEFOLDER='cache'; |
|
| 42 | - const CACHETIME=10*60; // secondes |
|
| 39 | + const ENDPOINT = 'https://www.windguru.cz'; |
|
| 40 | + const LOGFOLDER = 'logs'; |
|
| 41 | + const CACHEFOLDER = 'cache'; |
|
| 42 | + const CACHETIME = 10 * 60; // secondes |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Private Id of the Spot |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | $this->_httpClient = $httpClient ?: HttpClientDiscovery::find(); |
| 92 | 92 | $this->_messageFactory = $messageFactory ?: MessageFactoryDiscovery::find(); |
| 93 | 93 | |
| 94 | - if(!file_exists(self::CACHEFOLDER)) { |
|
| 94 | + if (!file_exists(self::CACHEFOLDER)) { |
|
| 95 | 95 | mkdir(self::CACHEFOLDER, 0777, true); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if(!file_exists(self::LOGFOLDER)) { |
|
| 98 | + if (!file_exists(self::LOGFOLDER)) { |
|
| 99 | 99 | mkdir(self::LOGFOLDER, 0777, true); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $this->_log = new Logger('WindguruAPI'); |
| 103 | - $this->_log->pushHandler(new StreamHandler(self::LOGFOLDER . '/' . date('Ymd') . '.log', Logger::WARNING)); |
|
| 103 | + $this->_log->pushHandler(new StreamHandler(self::LOGFOLDER.'/'.date('Ymd').'.log', Logger::WARNING)); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function getData() |
| 132 | 132 | { |
| 133 | - if(file_exists(self::CACHEFOLDER.'/'.$this->_idSpot)) { |
|
| 133 | + if (file_exists(self::CACHEFOLDER.'/'.$this->_idSpot)) { |
|
| 134 | 134 | $this->getCacheData(); |
| 135 | 135 | } else { |
| 136 | 136 | $this->getOnlineData(); |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | $number = 1; |
| 169 | 169 | |
| 170 | 170 | foreach ($nodes as $node) { |
| 171 | - if($node->nodeName == "script") { |
|
| 171 | + if ($node->nodeName == "script") { |
|
| 172 | 172 | $nodeData = $xml->addChild('tab'); |
| 173 | - $nodeData->addChild('number',$number); |
|
| 173 | + $nodeData->addChild('number', $number); |
|
| 174 | 174 | $nodeData->addChild( |
| 175 | 175 | 'wg_fcst_tab_data', |
| 176 | 176 | $this->extractVariableIntoScript( |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $this->_data = $xml; |
| 193 | 193 | $this->setCacheData(); |
| 194 | 194 | |
| 195 | - $this->_log->warning($this->_idSpot . ": Load online data."); |
|
| 195 | + $this->_log->warning($this->_idSpot.": Load online data."); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | private function extractVariableIntoScript($script, $variable) |
| 207 | 207 | { |
| 208 | - preg_match('/var ' . $variable . ' = (.*);/', $script, $m ); |
|
| 209 | - return $m[1]; |
|
| 208 | + preg_match('/var '.$variable.' = (.*);/', $script, $m); |
|
| 209 | + return $m[ 1 ]; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | { |
| 231 | 231 | $current = file_get_contents(self::CACHEFOLDER.'/'.$this->_idSpot); |
| 232 | 232 | $xml = new \SimpleXMLElement($current); |
| 233 | - if(time() - $xml['updated'] <= self::CACHETIME) { |
|
| 233 | + if (time() - $xml[ 'updated' ] <= self::CACHETIME) { |
|
| 234 | 234 | $this->_data = $xml; |
| 235 | - $this->_log->warning($this->_idSpot . ": Load cache data."); |
|
| 235 | + $this->_log->warning($this->_idSpot.": Load cache data."); |
|
| 236 | 236 | } else { |
| 237 | 237 | $this->getOnlineData(); |
| 238 | 238 | } |
@@ -11,18 +11,18 @@ |
||
| 11 | 11 | * @link https://github.com/voidtek/windguru.io |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -require_once __DIR__ . "/vendor/autoload.php"; |
|
| 14 | +require_once __DIR__."/vendor/autoload.php"; |
|
| 15 | 15 | |
| 16 | 16 | use voidtek\WindguruIO\WindguruAPI; |
| 17 | 17 | |
| 18 | 18 | if (PHP_SAPI === 'cli') { |
| 19 | - $idspot = $argv[1]; |
|
| 19 | + $idspot = $argv[ 1 ]; |
|
| 20 | 20 | } |
| 21 | 21 | else { |
| 22 | - $idspot = $_GET['idspot']; |
|
| 22 | + $idspot = $_GET[ 'idspot' ]; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if(empty($idspot)) return; |
|
| 25 | +if (empty($idspot)) return; |
|
| 26 | 26 | |
| 27 | 27 | $windguruAPI = new WindguruAPI(); |
| 28 | 28 | $windguruAPI->setSpot($idspot); |