Skip to content

Commit 22b82e3

Browse files
committed
cosmetic changes
1 parent ee13dbd commit 22b82e3

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

bootstrap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
call_user_func(function () {
2020
if (!is_file($autoloadFile = __DIR__ . './vendor/autoload.php')) {
21-
throw new \RuntimeException('Did not find vendor/autoload.php. Did you run "composer install --dev"?');
21+
throw new \RuntimeException('Did not find vendor/autoload.php. Did you run "composer install"?');
2222
}
2323

2424
/** @noinspection PhpIncludeInspection */

index.php

+20-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<meta http-equiv="X-UA-Compatible" content="ie=edge">
77
<title>OpenWeatherMap App</title>
8+
<style>
9+
.wrap{
10+
max-width: 320px;
11+
margin: 20px auto;
12+
}
13+
.wrap form{
14+
display: block;
15+
margin: auto;
16+
}
17+
</style>
818
</head>
919
<body>
10-
<form action="weather.php" method="GET">
11-
Podaj miasto: <input type="text" name="city"/><br/>
12-
<input type=submit value="Wyślij"/>
13-
</form>
20+
<div class="wrap">
21+
<form action="weather.php" method="GET">
22+
<p class="name">
23+
Podaj miasto: <input type="text" name="city"/>
24+
</p>
25+
<p class="submit">
26+
<input type=submit value="Wyślij"/>
27+
</p>
28+
</form>
29+
</div>
1430
</body>
1531
</html>

weather.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
error_reporting(0);
2+
// error_reporting(0);
33
/*
44
* OpenWeatherMap-PHP-API — A PHP API to parse weather data from https://OpenWeatherMap.org.
55
*
@@ -47,7 +47,7 @@ function getWeathers(){
4747
$this->mydata[$key]['temp'] = $weather->temperature->getValue();
4848
$this->mydata[$key]['humidity'] = $weather->humidity->getValue();
4949
$this->mydata[$key]['wind'] = $weather->wind->speed->getValue();
50-
$this->mydata[$key]['scores'] = 0;
50+
$this->mydata[$key]['score'] = 0;
5151
$this->mydata[$key]['time'] = $weather->lastUpdate->format('Y-m-d H:i:s');
5252
}
5353
}
@@ -61,7 +61,7 @@ function checkTemp(){
6161
});
6262

6363
foreach ($this->mydata as $key => $value) {
64-
$this->mydata[$key]['scores'] += (100 - 10 * (($key + 1) - 1)) * 0.6;
64+
$this->mydata[$key]['score'] += (100 - 10 * (($key + 1) - 1)) * 0.6;
6565
}
6666
}
6767

@@ -74,7 +74,7 @@ function checkWind(){
7474
});
7575

7676
foreach ($this->mydata as $key => $value) {
77-
$this->mydata[$key]['scores'] += (100 - 10 * (($key + 1) - 1)) * 0.3;
77+
$this->mydata[$key]['score'] += (100 - 10 * (($key + 1) - 1)) * 0.3;
7878
}
7979
}
8080

@@ -87,13 +87,13 @@ function checkHumidity(){
8787
});
8888

8989
foreach ($this->mydata as $key => $value) {
90-
$this->mydata[$key]['scores'] += (100 - 10 * (($key + 1) - 1)) * 0.1;
90+
$this->mydata[$key]['score'] += (100 - 10 * (($key + 1) - 1)) * 0.1;
9191
}
9292
}
9393

9494
function printScores(){
9595
usort($this->mydata, function($a,$b){
96-
$c = $b['scores'] - $a['scores'];
96+
$c = $b['score'] - $a['score'];
9797
$c .= $b['humidity'] - $a['humidity'];
9898
$c .= strcmp($a['wind'],$b['wind']);
9999
return $c;
@@ -102,8 +102,6 @@ function printScores(){
102102
header('Content-Type: application/json');
103103
echo json_encode($this->mydata, JSON_FORCE_OBJECT);
104104
}
105-
106-
107105
}
108106

109107
$weather = new MyWeather($myApiKey, $_GET['city']);

0 commit comments

Comments
 (0)