Skip to content

Commit 82f0d78

Browse files
committed
cleanup more
1 parent f5a75b7 commit 82f0d78

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

public/test.php

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,44 @@
1212

1313
require('../src/Weatherbit.php');
1414

15-
$call = isset($_GET['call']) ? $_GET['call'] : '';
16-
$key = isset($_GET['key']) ? $_GET['key'] : '';
17-
$city = isset($_GET['city']) ? $_GET['city'] : '';
18-
$country = isset($_GET['country']) ? $_GET['country'] : '';
19-
$days = isset($_GET['days']) ? intval($_GET['days']) : 1;
20-
$ip = isset($_GET['ip']) ? $_GET['ip'] : $_SERVER['REMOTE_ADDR'];
15+
$call = isset($_GET['call']) ? $_GET['call'] : '';
16+
$key = isset($_GET['key']) ? $_GET['key'] : '';
17+
$city = isset($_GET['city']) ? $_GET['city'] : '';
18+
$country = isset($_GET['country']) ? $_GET['country'] : '';
19+
$days = isset($_GET['days']) ? intval($_GET['days']) : 1;
20+
$ipAddress = isset($_GET['ip']) ? $_GET['ip'] : $_SERVER['REMOTE_ADDR'];
21+
22+
$selected = ' selected="selected"';
23+
$callSelected = [];
24+
$callSelected['forecast'] = ($call == 'forecast') ? $selected : '';
25+
$callSelected['current'] = ($call == 'current') ? $selected : '';
26+
$callSelected['usage'] = ($call == 'usage') ? $selected : '';
2127

2228
$pageTitle= 'Weatherbit v' . Weatherbit::VERSION . ' web test';
2329

24-
?>
25-
<html>
30+
print '<html>
2631
<head>
27-
<title><?= $pageTitle ?></title>
32+
<title>' . $pageTitle . '</title>
2833
</head>
2934
<body>
30-
<h1><?= $pageTitle ?></h1>
35+
<h1>' . $pageTitle . '</h1>
3136
<form>
3237
Call: <select name="call">
33-
<option value="forecast"<?= $call == 'forecast' ? ' selected="selected"' : '' ?>>Daily Weather Forecast</option>
34-
<option value="current"<?= $call == 'current' ? ' selected="selected"' : '' ?>>Current Weather</option>
35-
<option value="usage"<?= $call == 'usage' ? ' selected="selected"' : '' ?>>API Usage</option>
38+
<option value="forecast"' . $callSelected['forecast'] . '>Daily Weather Forecast</option>
39+
<option value="current"' . $callSelected['current'] . '>Current Weather</option>
40+
<option value="usage"' . $callSelected['usage'] . '>API Usage</option>
3641
</select><br /><br />
37-
API Key: <input name="key" type="text" value="<?= htmlentities($key) ?>" size="35" /><br /><br />
38-
City: <input name="city" type="text" value="<?= htmlentities($city) ?>" size="20" /><br /><br />
39-
Country: <input name="country" type="text" value="<?= htmlentities($country) ?>" size="2" maxlength="2" />
42+
API Key: <input name="key" type="text" value="' . htmlentities($key) . '" size="35" /><br /><br />
43+
City: <input name="city" type="text" value="' . htmlentities($city) . '" size="20" /><br /><br />
44+
Country: <input name="country" type="text" value="' . htmlentities($country) . '" size="2" maxlength="2" />
4045
(2 Letter Country Code)<br /><br />
41-
Forecast Days (1-16): <input name="days" type="text" value="<?= $days ?>" size="2" maxlength="2" /><br /><br />
42-
IP: <input name="ip" type="text" value="<?= $ip ?>" size="20" />
46+
Forecast Days (1-16): <input name="days" type="text" value="' . $days . '" size="2" maxlength="2" /><br /><br />
47+
IP Address: <input name="ip" type="text" value="' . $ipAddress . '" size="20" />
4348
<br /><br />
4449
<input type="hidden" name="run" value="test" />
4550
<input type="submit" value=" Get Weatherbit API Response " />
46-
&nbsp; &nbsp; <a href="<?= $_SERVER['PHP_SELF'] ?>">reset</a>
47-
</form>
48-
<?php
51+
&nbsp; &nbsp; <a href="' . $_SERVER['PHP_SELF'] . '">reset</a>
52+
</form>';
4953

5054
if (!isset($_GET['run']) || $_GET['run'] != 'test') {
5155
testFooter();
@@ -73,7 +77,8 @@
7377
$data = $weatherbit->getUsage();
7478
break;
7579
default:
76-
throw new Exception('Invalid Call type');
80+
$error = 'Invalid Call type';
81+
break;
7782
}
7883
} catch (Exception $error) {
7984
$error = $error->getMessage();

src/Weatherbit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class Weatherbit
2020
{
21-
const VERSION = '1.1.2';
21+
const VERSION = '1.1.3';
2222

2323
/**
2424
* @var string - user agent for API requests

0 commit comments

Comments
 (0)