| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 | |
| 61 | 61 | /** | 
| 62 | 62 | * Get current time | 
| 63 | - * @return bool|string | |
| 63 | + * @return string | |
| 64 | 64 | */ | 
| 65 | 65 |      public function getObservationTime() { | 
| 66 | 66 |          return $time = date("H:i",strtotime($this->observation_time)); | 
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | |
| 81 | 81 | /** | 
| 82 | 82 | * Get wind direction | 
| 83 | - * @return mixed | |
| 83 | + * @return string|null | |
| 84 | 84 | */ | 
| 85 | 85 |      public function getWindDirection() { | 
| 86 | 86 | $windDirection = [ | 
| @@ -52,7 +52,7 @@ discard block | ||
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | 54 |      public function getTemperatureFromTo() { | 
| 55 | - if($this->temperature_from && $this->temperature_to) | |
| 55 | + if ($this->temperature_from && $this->temperature_to) | |
| 56 | 56 | return $this->getTemperatureFromStr().'...'.$this->getTemperatureToStr(); | 
| 57 | 57 | else | 
| 58 | 58 | return $this->getTemperatureAvgStr(); | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | * @return bool|string | 
| 64 | 64 | */ | 
| 65 | 65 |      public function getObservationTime() { | 
| 66 | -        return $time = date("H:i",strtotime($this->observation_time)); | |
| 66 | +        return $time = date("H:i", strtotime($this->observation_time)); | |
| 67 | 67 | } | 
| 68 | 68 | |
| 69 | 69 | /** | 
| @@ -71,8 +71,8 @@ discard block | ||
| 71 | 71 | * @return mixed | 
| 72 | 72 | */ | 
| 73 | 73 |      public function getIcon() { | 
| 74 | -        if(substr($this->image_v3,  -3, 1) == "-") { | |
| 75 | -            $this->image_v3 =  str_replace("-", "", $this->image_v3); | |
| 74 | +        if (substr($this->image_v3, -3, 1) == "-") { | |
| 75 | +            $this->image_v3 = str_replace("-", "", $this->image_v3); | |
| 76 | 76 | } | 
| 77 | 77 |          $this->image_v3 = str_replace("+", "", $this->image_v3); | 
| 78 | 78 |          return str_replace("_", "-", $this->image_v3); | 
| @@ -83,7 +83,7 @@ discard block | ||
| 83 | 83 | * @return mixed | 
| 84 | 84 | */ | 
| 85 | 85 |      public function getWindDirection() { | 
| 86 | - $windDirection = [ | |
| 86 | + $windDirection = [ | |
| 87 | 87 | 's'=>'Ю', | 
| 88 | 88 | 'n'=>'С', | 
| 89 | 89 | 'w'=>'З', | 
| @@ -93,7 +93,7 @@ discard block | ||
| 93 | 93 | 'nw'=>'СЗ', | 
| 94 | 94 | 'ne'=>'СВ']; | 
| 95 | 95 | |
| 96 | - if(isset($windDirection[$this->wind_direction])) | |
| 96 | + if (isset($windDirection[$this->wind_direction])) | |
| 97 | 97 | return $windDirection[$this->wind_direction]; | 
| 98 | 98 | |
| 99 | 99 | return null; | 
| @@ -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 | |
| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | /** | 
| 3 | - * Created by PhpStorm. | |
| 4 | - * User: ignatenkov | |
| 5 | - * Date: 23.08.15 | |
| 6 | - * Time: 4:56 | |
| 7 | - */ | |
| 3 | + * Created by PhpStorm. | |
| 4 | + * User: ignatenkov | |
| 5 | + * Date: 23.08.15 | |
| 6 | + * Time: 4:56 | |
| 7 | + */ | |
| 8 | 8 | |
| 9 | 9 | namespace YaWeather\Models; | 
| 10 | 10 | |
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | //echo $this->getFilePath($value); | 
| 26 | 26 | $contents = file_get_contents($this->getFilePath($value)); | 
| 27 | 27 | |
| 28 | -            if(preg_match_all($this->pattern, $contents, $matches)){ | |
| 28 | +            if (preg_match_all($this->pattern, $contents, $matches)) { | |
| 29 | 29 | //echo "Found matches:\n"; | 
| 30 | 30 |                  //echo implode("\n", $matches[0]); | 
| 31 | 31 |                  foreach ($matches[0] as $val) { | 
| @@ -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); | 
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | |
| 9 | 9 | <?php | 
| 10 | 10 | |
| 11 | -require_once(__DIR__ . '/vendor/autoload.php'); | |
| 11 | +require_once(__DIR__.'/vendor/autoload.php'); | |
| 12 | 12 | |
| 13 | 13 | use YaWeather\YaWeather; | 
| 14 | 14 | |
| @@ -20,7 +20,7 @@ discard block | ||
| 20 | 20 | * Construct $id is cityId | 
| 21 | 21 | * @param int $id | 
| 22 | 22 | */ | 
| 23 | -        public function __construct($id = 27643, $url = "https://export.yandex.ru/weather-ng/forecasts/"){ | |
| 23 | +        public function __construct($id = 27643, $url = "https://export.yandex.ru/weather-ng/forecasts/") { | |
| 24 | 24 | $this->_citiyId = $id; | 
| 25 | 25 | $this->_url = $url; | 
| 26 | 26 | } | 
| @@ -41,8 +41,8 @@ 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)."."; | |
| 44 | + if (curl_errno($ch)) | |
| 45 | + $this->_error[] = "Error load weather from web. curl_error output: ".curl_error($ch)."."; | |
| 46 | 46 | else | 
| 47 | 47 | $this->_success[] = "Load weather from web OK."; | 
| 48 | 48 | $this->saveToFile($output); | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 | |
| 58 | 58 | $fh = fopen($fileName, 'w'); | 
| 59 | 59 | |
| 60 | - if(fwrite($fh, $output)) | |
| 60 | + if (fwrite($fh, $output)) | |
| 61 | 61 | $this->_success[] = "File success write."; | 
| 62 | 62 | else | 
| 63 | 63 | $this->_error[] = "Error file save."; | 
| @@ -71,9 +71,9 @@ discard block | ||
| 71 | 71 |          public function logFormat() { | 
| 72 | 72 | $str = ""; | 
| 73 | 73 | |
| 74 | - if($this->_error) | |
| 74 | + if ($this->_error) | |
| 75 | 75 |                  $str .= "Error: ".implode(" ", $this->_error)."<br>"; | 
| 76 | - if($this->_success) | |
| 76 | + if ($this->_success) | |
| 77 | 77 |                  $str .= "Success: ".implode(" ", $this->_success)."<br>"; | 
| 78 | 78 | |
| 79 | 79 | return $str; | 
| @@ -91,7 +91,7 @@ discard block | ||
| 91 | 91 | * Get success | 
| 92 | 92 | * @return array | 
| 93 | 93 | */ | 
| 94 | -        public function getSuccess(){ | |
| 94 | +        public function getSuccess() { | |
| 95 | 95 | return $this->_success; | 
| 96 | 96 | } | 
| 97 | 97 | |
| @@ -104,7 +104,7 @@ discard block | ||
| 104 | 104 | |
| 105 | 105 | $parse = new ParseXml($this->getFileName()); | 
| 106 | 106 | |
| 107 | - if($parse->parse()) | |
| 107 | + if ($parse->parse()) | |
| 108 | 108 | return $parse->parse(); | 
| 109 | 109 | else | 
| 110 | 110 | return false; | 
| @@ -117,14 +117,14 @@ discard block | ||
| 117 | 117 | */ | 
| 118 | 118 |          public function show($cp1251 = false) { | 
| 119 | 119 | $file = "html.php"; | 
| 120 | - if($cp1251) | |
| 120 | + if ($cp1251) | |
| 121 | 121 | $file = "htmlcp1251.php"; | 
| 122 | 122 | |
| 123 | 123 | $city = $this->getResult(); | 
| 124 | 124 | |
| 125 | 125 | $path = str_replace($_SERVER['DOCUMENT_ROOT'], "", __DIR__)."./../css"; | 
| 126 | 126 | |
| 127 | - if($city != null) | |
| 127 | + if ($city != null) | |
| 128 | 128 | require_once(dirname(__DIR__).'/'.$file); | 
| 129 | 129 | } | 
| 130 | 130 | |
| @@ -133,7 +133,7 @@ discard block | ||
| 133 | 133 | * @return string | 
| 134 | 134 | */ | 
| 135 | 135 |          private function CreateUrl() { | 
| 136 | - return $this->_url . $this->_citiyId .".xml"; | |
| 136 | + return $this->_url.$this->_citiyId.".xml"; | |
| 137 | 137 | } | 
| 138 | 138 | |
| 139 | 139 | /** | 
| @@ -141,7 +141,7 @@ discard block | ||
| 141 | 141 | * @return string | 
| 142 | 142 | */ | 
| 143 | 143 |          public function getFileName() { | 
| 144 | - return dirname(__DIR__)."/city_" . $this->_citiyId . ".xml"; | |
| 144 | + return dirname(__DIR__)."/city_".$this->_citiyId.".xml"; | |
| 145 | 145 | } | 
| 146 | 146 | |
| 147 | 147 | } | 
| @@ -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,7 +27,7 @@ discard block | ||
| 27 | 27 | */ | 
| 28 | 28 |      public function getCurrentDay() { | 
| 29 | 29 |          $current = date("Y-m-d"); | 
| 30 | - if(isset($this->days[$current])) | |
| 30 | + if (isset($this->days[$current])) | |
| 31 | 31 | return $this->days[$current]; | 
| 32 | 32 | else | 
| 33 | 33 | return "not found current day"; | 
| @@ -39,7 +39,7 @@ discard block | ||
| 39 | 39 | */ | 
| 40 | 40 |      public function getListDays() { | 
| 41 | 41 |          $current = date("Y-m-d"); | 
| 42 | - if(isset($this->days[$current])) | |
| 42 | + if (isset($this->days[$current])) | |
| 43 | 43 | unset($this->days[$current]); | 
| 44 | 44 | |
| 45 | 45 | return $this->days; | 
| @@ -52,7 +52,7 @@ discard block | ||
| 52 | 52 |      public function getYesterday() { | 
| 53 | 53 |          $yesterday = date("Y-m-d", time() - 86400); | 
| 54 | 54 | |
| 55 | - if(isset($this->days[$yesterday])) | |
| 55 | + if (isset($this->days[$yesterday])) | |
| 56 | 56 | return $this->days[$yesterday]; | 
| 57 | 57 | else | 
| 58 | 58 | return "not found yesterday day"; | 
| @@ -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 | |
| @@ -9,7 +9,7 @@ discard block | ||
| 9 | 9 | namespace YaWeather\Models; | 
| 10 | 10 | |
| 11 | 11 | |
| 12 | -class Day{ | |
| 12 | +class Day { | |
| 13 | 13 | |
| 14 | 14 | const TYPE_MORNING = 1; | 
| 15 | 15 | const TYPE_DAY = 2; | 
| @@ -44,7 +44,7 @@ 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)) | |
| 47 | + if ($weekend && ($dayNumber == 0 || $dayNumber == 6)) | |
| 48 | 48 | return true; | 
| 49 | 49 | elseif ($weekend == false && $dayNumber == 0) | 
| 50 | 50 | return true; | 
| @@ -57,19 +57,19 @@ discard block | ||
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 |      public static function getMonthName($value) { | 
| 60 | - $listMonths = ['','января','февраля','марта','апреля','мая','июня','июля','августа','сентября','октября','ноября','декабря']; | |
| 60 | + $listMonths = ['', 'января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря']; | |
| 61 | 61 |          return $listMonths[date("n", strtotime($value))]; | 
| 62 | 62 | } | 
| 63 | 63 | |
| 64 | 64 |      public static function getDayName($value) { | 
| 65 | 65 | $str = ""; | 
| 66 | 66 | |
| 67 | - $listDays = ['вс','пн', 'вт', 'ср', 'чт', 'пт', 'сб']; | |
| 67 | + $listDays = ['вс', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб']; | |
| 68 | 68 | |
| 69 | 69 |          $date = Date('d.m.Y', strtotime("+1 days")); | 
| 70 | 70 |          $match_date = date('d.m.Y', strtotime($value)); | 
| 71 | 71 | |
| 72 | - if($date == $match_date) | |
| 72 | + if ($date == $match_date) | |
| 73 | 73 | $str = "Завтра"; | 
| 74 | 74 |          else { | 
| 75 | 75 |              $str = $listDays[date("w", strtotime($value))]; | 
| @@ -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,18 +36,18 @@ discard block | ||
| 36 | 36 |      public function parse() { | 
| 37 | 37 | |
| 38 | 38 | // check xml load | 
| 39 | - if(!$this->xml) | |
| 39 | + if (!$this->xml) | |
| 40 | 40 | return false; | 
| 41 | 41 | |
| 42 | 42 | $city = new City(); | 
| 43 | -        foreach($this->xml->attributes() as $key => $value) { | |
| 44 | - if(isset(Mapping::mapCity()[$key])) | |
| 43 | +        foreach ($this->xml->attributes() as $key => $value) { | |
| 44 | + if (isset(Mapping::mapCity()[$key])) | |
| 45 | 45 |                  $city->{Mapping::mapCity()[$key]} = (string) $value; | 
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | 48 | $fact = new Detail(); | 
| 49 | 49 |          foreach ($this->xml->fact[0] as $key => $value) { | 
| 50 | -            if(isset(Mapping::mapDetail()[$key])) { | |
| 50 | +            if (isset(Mapping::mapDetail()[$key])) { | |
| 51 | 51 |                  $fact->{Mapping::mapDetail()[$key]} = (string) $value; | 
| 52 | 52 | } | 
| 53 | 53 | |
| @@ -56,7 +56,7 @@ discard block | ||
| 56 | 56 | |
| 57 | 57 | $fact = new Detail(); | 
| 58 | 58 |          foreach ($this->xml->yesterday[0] as $key => $value) { | 
| 59 | -            if(isset(Mapping::mapDetail()[$key])) { | |
| 59 | +            if (isset(Mapping::mapDetail()[$key])) { | |
| 60 | 60 |                  $fact->{Mapping::mapDetail()[$key]} = (string) $value; | 
| 61 | 61 | } | 
| 62 | 62 | |
| @@ -64,10 +64,10 @@ discard block | ||
| 64 | 64 | $city->yesterday = $fact; | 
| 65 | 65 | |
| 66 | 66 | $days = array(); | 
| 67 | -        foreach($this->xml->day as $value) { | |
| 67 | +        foreach ($this->xml->day as $value) { | |
| 68 | 68 | $day = new Day(); | 
| 69 | 69 |              foreach ($value as $key => $value1) { | 
| 70 | -                if(isset(Mapping::mapDay()[$key])) { | |
| 70 | +                if (isset(Mapping::mapDay()[$key])) { | |
| 71 | 71 |                      $day->{Mapping::mapDay()[$key]} = (string) $value1; | 
| 72 | 72 | } | 
| 73 | 73 | //var_dump($value1->attributes()["typeid"]); | 
| @@ -77,16 +77,16 @@ discard block | ||
| 77 | 77 |              foreach ($value->day_part as $key2 => $value2) { | 
| 78 | 78 | $detail = new Detail(); | 
| 79 | 79 |                  foreach ($value2 as $key3 => $value3) { | 
| 80 | -                    if(isset(Mapping::mapDetail()[$key3])) { | |
| 80 | +                    if (isset(Mapping::mapDetail()[$key3])) { | |
| 81 | 81 |                          $detail->{Mapping::mapDetail()[$key3]} = (string) $value3; | 
| 82 | 82 | } | 
| 83 | -                    if(isset(Mapping::mapDetail()["inner"][$key3])) { | |
| 83 | +                    if (isset(Mapping::mapDetail()["inner"][$key3])) { | |
| 84 | 84 |                          $detail->{Mapping::mapDetail()["inner"][$key3]} = (string) $value3->avg; | 
| 85 | 85 | } | 
| 86 | 86 | } | 
| 87 | 87 |                  $day->{$value2->attributes()["type"]} = $detail; | 
| 88 | 88 | } | 
| 89 | - $days[(string)$value->attributes()["date"]] = $day; | |
| 89 | + $days[(string) $value->attributes()["date"]] = $day; | |
| 90 | 90 | } | 
| 91 | 91 | $city->days = $days; | 
| 92 | 92 | |
| @@ -99,7 +99,7 @@ discard block | ||
| 99 | 99 | * @return string | 
| 100 | 100 | */ | 
| 101 | 101 |      public static function encoding($value) { | 
| 102 | - return iconv( "UTF-8", "windows-1251//TRANSLIT", $value); | |
| 102 | +        return iconv("UTF-8", "windows-1251//TRANSLIT", $value); | |
| 103 | 103 | } | 
| 104 | 104 | |
| 105 | 105 | |
| @@ -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(); | 
| @@ -58,21 +58,21 @@ discard block | ||
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | echo '<li class="forecast-brief__item"> | 
| 61 | - <div class="forecast-brief__item-date ' . ($day->checkWeekend($key, true) ? "forecast-brief__item-date_weekend_yes" : "") . '"><span | |
| 62 | - class="forecast-brief__item-dayname">' . $day->getDayName($key) . '</span><span | |
| 63 | - class="forecast-brief__item-day">' . $day->getDayNumber($key) . ' ' . ($i > 0 ? "" : $day->getMonthName($key)) . '</span></div> | |
| 64 | - <div class="forecast-brief__item-description t_c_' . $day->day->temperature_avg . '"><i | |
| 65 | - class="icon icon_thumb_' . $day->day->getIcon() . ' icon_size_30" data-width="30"></i> | |
| 61 | + <div class="forecast-brief__item-date ' . ($day->checkWeekend($key, true) ? "forecast-brief__item-date_weekend_yes" : "").'"><span | |
| 62 | + class="forecast-brief__item-dayname">' . $day->getDayName($key).'</span><span | |
| 63 | + class="forecast-brief__item-day">' . $day->getDayNumber($key).' '.($i > 0 ? "" : $day->getMonthName($key)).'</span></div> | |
| 64 | + <div class="forecast-brief__item-description t_c_' . $day->day->temperature_avg.'"><i | |
| 65 | + class="icon icon_thumb_' . $day->day->getIcon().' icon_size_30" data-width="30"></i> | |
| 66 | 66 | |
| 67 | - <div class="forecast-brief__item-comment">' . $day->day->weather_type . '</div> | |
| 67 | + <div class="forecast-brief__item-comment">' . $day->day->weather_type.'</div> | |
| 68 | 68 | <div class="forecast-brief__item-temp-day" title="Максимальная температура днём"> | 
| 69 | - ' . $day->day->getTemperatureAvgStr() . ' | |
| 70 | - ' . ($i > 0 ? "" : "днём") . ' | |
| 69 | + ' . $day->day->getTemperatureAvgStr().' | |
| 70 | + ' . ($i > 0 ? "" : "днём").' | |
| 71 | 71 | </div> | 
| 72 | 72 | </div> | 
| 73 | - <div class="forecast-brief__item-temp-night t_c_' . $day->night->temperature_avg . '" title="Минимальная температура ночью"> | |
| 74 | - ' . $day->night->getTemperatureAvgStr() . ' | |
| 75 | - ' . ($i > 0 ? "" : "ночью") . ' | |
| 73 | + <div class="forecast-brief__item-temp-night t_c_' . $day->night->temperature_avg.'" title="Минимальная температура ночью"> | |
| 74 | + ' . $day->night->getTemperatureAvgStr().' | |
| 75 | + ' . ($i > 0 ? "" : "ночью").' | |
| 76 | 76 | </div> | 
| 77 | 77 | </li>'; | 
| 78 | 78 | |
| @@ -98,14 +98,14 @@ discard block | ||
| 98 | 98 | |
| 99 | 99 | <?php | 
| 100 | 100 | $i = 0; | 
| 101 | -                    foreach($city->getListDays() as $key => $day){ | |
| 101 | +                    foreach ($city->getListDays() as $key => $day) { | |
| 102 | 102 | |
| 103 | - echo '<dt class="forecast-detailed__day ' . ($day->checkWeekend($key, true) ? "forecast-detailed__day_weekend" : "") . '"> | |
| 104 | - <small class="forecast-detailed__weekday">' . $day->getDayName($key) . '</small> | |
| 105 | - <strong class="forecast-detailed__day-number">' . $day->getDayNumber($key) . '<span class="forecast-detailed__day-month">'.$day->getMonthName($key).'</span></strong> | |
| 103 | + echo '<dt class="forecast-detailed__day '.($day->checkWeekend($key, true) ? "forecast-detailed__day_weekend" : "").'"> | |
| 104 | + <small class="forecast-detailed__weekday">' . $day->getDayName($key).'</small> | |
| 105 | + <strong class="forecast-detailed__day-number">' . $day->getDayNumber($key).'<span class="forecast-detailed__day-month">'.$day->getMonthName($key).'</span></strong> | |
| 106 | 106 | </dt>'; | 
| 107 | 107 | |
| 108 | - echo '<dd class="forecast-detailed__day-info '.($i<1 ? "forecast-detailed__day-info_first": "").'"> | |
| 108 | + echo '<dd class="forecast-detailed__day-info '.($i < 1 ? "forecast-detailed__day-info_first" : "").'"> | |
| 109 | 109 | <table class="weather-table"> | 
| 110 | 110 | <thead class="weather-table__head"> | 
| 111 | 111 | <tr> | 
| @@ -126,7 +126,7 @@ discard block | ||
| 126 | 126 | |
| 127 | 127 |                          foreach ($day->getListDetail() as $key => $detail) { | 
| 128 | 128 | |
| 129 | - echo '<tr class="weather-table__row t t_c_' . $detail->temperature_avg . '"> | |
| 129 | + echo '<tr class="weather-table__row t t_c_'.$detail->temperature_avg.'"> | |
| 130 | 130 | <td class="weather-table__body-cell weather-table__body-cell_type_daypart"> | 
| 131 | 131 | <div class="weather-table__daypart">'.$key.'</div> | 
| 132 | 132 | <div class="weather-table__temp">'.$detail->getTemperatureFromTo().'</div> | 
| @@ -136,7 +136,7 @@ discard block | ||
| 136 | 136 | data-width="30"></i></div> | 
| 137 | 137 | </td> | 
| 138 | 138 | <td class="weather-table__body-cell weather-table__body-cell_type_condition"> | 
| 139 | - <div class="weather-table__value">' . $detail->weather_type . '</div> | |
| 139 | + <div class="weather-table__value">' . $detail->weather_type.'</div> | |
| 140 | 140 | </td> | 
| 141 | 141 | <td class="weather-table__body-cell weather-table__body-cell_type_air-pressure"> | 
| 142 | 142 | <div class="weather-table__value">'.$detail->pressure.'</div> |