@@ -39,8 +39,9 @@ |
||
39 | 39 | $path = "img/".$path; |
40 | 40 | //echo $path . " - " . $fileName."<br>"; |
41 | 41 | |
42 | - if (!file_exists($path)) |
|
43 | - mkdir($path, 0777, true); |
|
42 | + if (!file_exists($path)) { |
|
43 | + mkdir($path, 0777, true); |
|
44 | + } |
|
44 | 45 | |
45 | 46 | $image = file_get_contents("https://".$val); |
46 | 47 | file_put_contents($path.$fileName, $image); |
@@ -41,10 +41,11 @@ discard block |
||
41 | 41 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
42 | 42 | $output = curl_exec($ch); |
43 | 43 | |
44 | - if(curl_errno($ch)) |
|
45 | - $this->_error[] = "Error load weather from web. curl_error output: " .curl_error($ch)."."; |
|
46 | - else |
|
47 | - $this->_success[] = "Load weather from web OK."; |
|
44 | + if(curl_errno($ch)) { |
|
45 | + $this->_error[] = "Error load weather from web. curl_error output: " .curl_error($ch)."."; |
|
46 | + } else { |
|
47 | + $this->_success[] = "Load weather from web OK."; |
|
48 | + } |
|
48 | 49 | $this->saveToFile($output); |
49 | 50 | } |
50 | 51 | |
@@ -57,10 +58,11 @@ discard block |
||
57 | 58 | |
58 | 59 | $fh = fopen($fileName, 'w'); |
59 | 60 | |
60 | - if(fwrite($fh, $output)) |
|
61 | - $this->_success[] = "File success write."; |
|
62 | - else |
|
63 | - $this->_error[] = "Error file save."; |
|
61 | + if(fwrite($fh, $output)) { |
|
62 | + $this->_success[] = "File success write."; |
|
63 | + } else { |
|
64 | + $this->_error[] = "Error file save."; |
|
65 | + } |
|
64 | 66 | fclose($fh); |
65 | 67 | } |
66 | 68 | |
@@ -71,10 +73,12 @@ discard block |
||
71 | 73 | public function logFormat() { |
72 | 74 | $str = ""; |
73 | 75 | |
74 | - if($this->_error) |
|
75 | - $str .= "Error: ".implode(" ", $this->_error)."<br>"; |
|
76 | - if($this->_success) |
|
77 | - $str .= "Success: ".implode(" ", $this->_success)."<br>"; |
|
76 | + if($this->_error) { |
|
77 | + $str .= "Error: ".implode(" ", $this->_error)."<br>"; |
|
78 | + } |
|
79 | + if($this->_success) { |
|
80 | + $str .= "Success: ".implode(" ", $this->_success)."<br>"; |
|
81 | + } |
|
78 | 82 | |
79 | 83 | return $str; |
80 | 84 | } |
@@ -104,10 +108,11 @@ discard block |
||
104 | 108 | |
105 | 109 | $parse = new ParseXml($this->getFileName()); |
106 | 110 | |
107 | - if($parse->parse()) |
|
108 | - return $parse->parse(); |
|
109 | - else |
|
110 | - return false; |
|
111 | + if($parse->parse()) { |
|
112 | + return $parse->parse(); |
|
113 | + } else { |
|
114 | + return false; |
|
115 | + } |
|
111 | 116 | |
112 | 117 | } |
113 | 118 | |
@@ -117,15 +122,17 @@ discard block |
||
117 | 122 | */ |
118 | 123 | public function show($cp1251 = false) { |
119 | 124 | $file = "html.php"; |
120 | - if($cp1251) |
|
121 | - $file = "htmlcp1251.php"; |
|
125 | + if($cp1251) { |
|
126 | + $file = "htmlcp1251.php"; |
|
127 | + } |
|
122 | 128 | |
123 | 129 | $city = $this->getResult(); |
124 | 130 | |
125 | 131 | $path = str_replace($_SERVER['DOCUMENT_ROOT'], "", __DIR__)."./../css"; |
126 | 132 | |
127 | - if($city != null) |
|
128 | - require_once(dirname(__DIR__).'/'.$file); |
|
133 | + if($city != null) { |
|
134 | + require_once(dirname(__DIR__).'/'.$file); |
|
135 | + } |
|
129 | 136 | } |
130 | 137 | |
131 | 138 | /** |
@@ -27,10 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function getCurrentDay() { |
29 | 29 | $current = date("Y-m-d"); |
30 | - if(isset($this->days[$current])) |
|
31 | - return $this->days[$current]; |
|
32 | - else |
|
33 | - return "not found current day"; |
|
30 | + if(isset($this->days[$current])) { |
|
31 | + return $this->days[$current]; |
|
32 | + } else { |
|
33 | + return "not found current day"; |
|
34 | + } |
|
34 | 35 | } |
35 | 36 | |
36 | 37 | /** |
@@ -39,8 +40,9 @@ discard block |
||
39 | 40 | */ |
40 | 41 | public function getListDays() { |
41 | 42 | $current = date("Y-m-d"); |
42 | - if(isset($this->days[$current])) |
|
43 | - unset($this->days[$current]); |
|
43 | + if(isset($this->days[$current])) { |
|
44 | + unset($this->days[$current]); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | return $this->days; |
46 | 48 | } |
@@ -52,10 +54,11 @@ discard block |
||
52 | 54 | public function getYesterday() { |
53 | 55 | $yesterday = date("Y-m-d", time() - 86400); |
54 | 56 | |
55 | - if(isset($this->days[$yesterday])) |
|
56 | - return $this->days[$yesterday]; |
|
57 | - else |
|
58 | - return "not found yesterday day"; |
|
57 | + if(isset($this->days[$yesterday])) { |
|
58 | + return $this->days[$yesterday]; |
|
59 | + } else { |
|
60 | + return "not found yesterday day"; |
|
61 | + } |
|
59 | 62 | } |
60 | 63 | |
61 | 64 |
@@ -52,10 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | public function getTemperatureFromTo() { |
55 | - if($this->temperature_from && $this->temperature_to) |
|
56 | - return $this->getTemperatureFromStr().'...'.$this->getTemperatureToStr(); |
|
57 | - else |
|
58 | - return $this->getTemperatureAvgStr(); |
|
55 | + if($this->temperature_from && $this->temperature_to) { |
|
56 | + return $this->getTemperatureFromStr().'...'.$this->getTemperatureToStr(); |
|
57 | + } else { |
|
58 | + return $this->getTemperatureAvgStr(); |
|
59 | + } |
|
59 | 60 | } |
60 | 61 | |
61 | 62 | /** |
@@ -93,8 +94,9 @@ discard block |
||
93 | 94 | 'nw'=>'СЗ', |
94 | 95 | 'ne'=>'СВ']; |
95 | 96 | |
96 | - if(isset($windDirection[$this->wind_direction])) |
|
97 | - return $windDirection[$this->wind_direction]; |
|
97 | + if(isset($windDirection[$this->wind_direction])) { |
|
98 | + return $windDirection[$this->wind_direction]; |
|
99 | + } |
|
98 | 100 | |
99 | 101 | return null; |
100 | 102 |
@@ -44,12 +44,13 @@ discard block |
||
44 | 44 | public static function CheckWeekend($value, $weekend = false) |
45 | 45 | { |
46 | 46 | $dayNumber = date('w', strtotime($value)); |
47 | - if($weekend && ($dayNumber == 0 || $dayNumber == 6)) |
|
48 | - return true; |
|
49 | - elseif ($weekend == false && $dayNumber == 0) |
|
50 | - return true; |
|
51 | - else |
|
52 | - return false; |
|
47 | + if($weekend && ($dayNumber == 0 || $dayNumber == 6)) { |
|
48 | + return true; |
|
49 | + } elseif ($weekend == false && $dayNumber == 0) { |
|
50 | + return true; |
|
51 | + } else { |
|
52 | + return false; |
|
53 | + } |
|
53 | 54 | } |
54 | 55 | |
55 | 56 | public static function getDayNumber($value) { |
@@ -69,9 +70,9 @@ discard block |
||
69 | 70 | $date = Date('d.m.Y', strtotime("+1 days")); |
70 | 71 | $match_date = date('d.m.Y', strtotime($value)); |
71 | 72 | |
72 | - if($date == $match_date) |
|
73 | - $str = "Завтра"; |
|
74 | - else { |
|
73 | + if($date == $match_date) { |
|
74 | + $str = "Завтра"; |
|
75 | + } else { |
|
75 | 76 | $str = $listDays[date("w", strtotime($value))]; |
76 | 77 | |
77 | 78 | //return $this->days[date('w', $date)].', '.(int)date('d',$date).' '.$this->months[date('n', $date)]; |
@@ -36,13 +36,15 @@ |
||
36 | 36 | public function parse() { |
37 | 37 | |
38 | 38 | // check xml load |
39 | - if(!$this->xml) |
|
40 | - return false; |
|
39 | + if(!$this->xml) { |
|
40 | + return false; |
|
41 | + } |
|
41 | 42 | |
42 | 43 | $city = new City(); |
43 | 44 | foreach($this->xml->attributes() as $key => $value) { |
44 | - if(isset(Mapping::mapCity()[$key])) |
|
45 | - $city->{Mapping::mapCity()[$key]} = (string) $value; |
|
45 | + if(isset(Mapping::mapCity()[$key])) { |
|
46 | + $city->{Mapping::mapCity()[$key]} = (string) $value; |
|
47 | + } |
|
46 | 48 | } |
47 | 49 | |
48 | 50 | $fact = new Detail(); |