@@ -106,7 +106,6 @@ discard block |
||
| 106 | 106 | /** |
| 107 | 107 | * Set the Id of the Spot. |
| 108 | 108 | * |
| 109 | - * @param string $someArgument The Argument for this call. |
|
| 110 | 109 | */ |
| 111 | 110 | public function setSpot($idSpot) |
| 112 | 111 | { |
@@ -212,7 +211,6 @@ discard block |
||
| 212 | 211 | /** |
| 213 | 212 | * Set the data of the Spot on cache. |
| 214 | 213 | * |
| 215 | - * @param string $data The Data. |
|
| 216 | 214 | */ |
| 217 | 215 | private function setCacheData() |
| 218 | 216 | { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * Example: 'https://www.windguru.cz/int/iapi.php?q=ads_spot&id_spot%5B%5D=42' |
| 36 | 36 | * |
| 37 | 37 | * @var string; |
| 38 | - */ |
|
| 38 | + */ |
|
| 39 | 39 | const ENDPOINT='https://www.windguru.cz'; |
| 40 | 40 | const LOGFOLDER='logs'; |
| 41 | 41 | const CACHEFOLDER='cache'; |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | $this->_messageFactory = $messageFactory ?: MessageFactoryDiscovery::find(); |
| 93 | 93 | |
| 94 | 94 | if(!file_exists(self::CACHEFOLDER)) { |
| 95 | - mkdir(self::CACHEFOLDER, 0777, true); |
|
| 95 | + mkdir(self::CACHEFOLDER, 0777, true); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if(!file_exists(self::LOGFOLDER)) { |
| 99 | - mkdir(self::LOGFOLDER, 0777, true); |
|
| 99 | + mkdir(self::LOGFOLDER, 0777, true); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $this->_log = new Logger('WindguruAPI'); |
@@ -130,11 +130,11 @@ 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 | - } else { |
|
| 135 | + } else { |
|
| 136 | 136 | $this->getOnlineData(); |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -168,25 +168,25 @@ 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 | 173 | $nodeData->addChild('number',$number); |
| 174 | 174 | $nodeData->addChild( |
| 175 | - 'wg_fcst_tab_data', |
|
| 176 | - $this->extractVariableIntoScript( |
|
| 175 | + 'wg_fcst_tab_data', |
|
| 176 | + $this->extractVariableIntoScript( |
|
| 177 | 177 | $node->nodeValue, |
| 178 | 178 | 'wg_fcst_tab_data_'.$number |
| 179 | - ) |
|
| 179 | + ) |
|
| 180 | 180 | ); |
| 181 | 181 | $nodeData->addChild( |
| 182 | - 'wgopts', |
|
| 183 | - $this->extractVariableIntoScript( |
|
| 182 | + 'wgopts', |
|
| 183 | + $this->extractVariableIntoScript( |
|
| 184 | 184 | $node->nodeValue, |
| 185 | 185 | 'wgopts_'.$number |
| 186 | - ) |
|
| 186 | + ) |
|
| 187 | 187 | ); |
| 188 | 188 | $number++; |
| 189 | - } |
|
| 189 | + } |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $this->_data = $xml; |
@@ -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 | /** |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | private function setCacheData() |
| 218 | 218 | { |
| 219 | - // todo assert notNull $this->_data. |
|
| 219 | + // todo assert notNull $this->_data. |
|
| 220 | 220 | |
| 221 | - file_put_contents(self::CACHEFOLDER.'/'.$this->_idSpot, $this->_data->asXML()); |
|
| 221 | + file_put_contents(self::CACHEFOLDER.'/'.$this->_idSpot, $this->_data->asXML()); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | private function getCacheData() |
| 230 | 230 | { |
| 231 | - $current = file_get_contents(self::CACHEFOLDER.'/'.$this->_idSpot); |
|
| 232 | - $xml = new \SimpleXMLElement($current); |
|
| 233 | - if(time() - $xml['updated'] <= self::CACHETIME) { |
|
| 231 | + $current = file_get_contents(self::CACHEFOLDER.'/'.$this->_idSpot); |
|
| 232 | + $xml = new \SimpleXMLElement($current); |
|
| 233 | + if(time() - $xml['updated'] <= self::CACHETIME) { |
|
| 234 | 234 | $this->_data = $xml; |
| 235 | 235 | $this->_log->warning($this->_idSpot . ": Load cache data."); |
| 236 | - } else { |
|
| 236 | + } else { |
|
| 237 | 237 | $this->getOnlineData(); |
| 238 | - } |
|
| 238 | + } |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | } |