Skip to content

Commit 72f6971

Browse files
authored
Merge pull request #24 from programmatordev/OPA-25-provide-units-according-to-measurement-system
Provide units according to measurement system
2 parents 4ffc5f9 + 3c8c35b commit 72f6971

File tree

9 files changed

+56
-7
lines changed

9 files changed

+56
-7
lines changed

src/Config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use ProgrammatorDev\OpenWeatherMap\HttpClient\HttpClientBuilder;
66
use ProgrammatorDev\OpenWeatherMap\HttpClient\Plugin\LoggerPlugin;
7+
use ProgrammatorDev\OpenWeatherMap\Language\Language;
8+
use ProgrammatorDev\OpenWeatherMap\MeasurementSystem\MeasurementSystem;
79
use ProgrammatorDev\OpenWeatherMap\Validator\BlankValidatorTrait;
810
use ProgrammatorDev\OpenWeatherMap\Validator\ChoiceValidatorTrait;
911
use Psr\Cache\CacheItemPoolInterface;

src/Endpoint/Util/WithLanguageTrait.php

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

33
namespace ProgrammatorDev\OpenWeatherMap\Endpoint\Util;
44

5-
use ProgrammatorDev\OpenWeatherMap\Language;
5+
use ProgrammatorDev\OpenWeatherMap\Language\Language;
66
use ProgrammatorDev\OpenWeatherMap\Validator\ChoiceValidatorTrait;
77

88
trait WithLanguageTrait

src/Endpoint/Util/WithMeasurementSystemTrait.php

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

33
namespace ProgrammatorDev\OpenWeatherMap\Endpoint\Util;
44

5-
use ProgrammatorDev\OpenWeatherMap\MeasurementSystem;
5+
use ProgrammatorDev\OpenWeatherMap\MeasurementSystem\MeasurementSystem;
66
use ProgrammatorDev\OpenWeatherMap\Validator\ChoiceValidatorTrait;
77

88
trait WithMeasurementSystemTrait

src/HttpClient/Plugin/LoggerPlugin.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
use Http\Client\Exception;
77
use Http\Message\Formatter;
88
use Http\Message\Formatter\SimpleFormatter;
9+
use Http\Promise\Promise;
910
use Psr\Http\Message\RequestInterface;
1011
use Psr\Http\Message\ResponseInterface;
1112
use Psr\Log\LoggerInterface;
1213

1314
class LoggerPlugin implements Plugin
1415
{
15-
use Plugin\VersionBridgePlugin;
16-
1716
private LoggerInterface $logger;
1817

1918
private Formatter $formatter;
@@ -27,7 +26,7 @@ public function __construct(LoggerInterface $logger, Formatter $formatter = null
2726
/**
2827
* @throws Exception
2928
*/
30-
protected function doHandleRequest(RequestInterface $request, callable $next, callable $first)
29+
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
3130
{
3231
$start = hrtime(true) / 1E6;
3332
$this->logger->info(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace ProgrammatorDev\OpenWeatherMap;
3+
namespace ProgrammatorDev\OpenWeatherMap\Language;
44

55
class Language
66
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace ProgrammatorDev\OpenWeatherMap\MeasurementSystem;
4+
5+
class Fahrenheit
6+
{
7+
public const ATMOSPHERIC_PRESSURE_UNIT = 'hPa';
8+
public const CLOUDINESS_UNIT = '%';
9+
public const HUMIDITY_UNIT = '%';
10+
public const POLLUTANT_CONCENTRATION_UNIT = 'μg/m3';
11+
public const PRECIPITATION_UNIT = 'mm';
12+
public const PRECIPITATION_PROBABILITY_UNIT = '%';
13+
public const SPEED_UNIT = 'mph';
14+
public const TEMPERATURE_UNIT = '°F';
15+
public const VISIBILITY_UNIT = 'km';
16+
}

src/MeasurementSystem/Imperial.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace ProgrammatorDev\OpenWeatherMap\MeasurementSystem;
4+
5+
class Imperial
6+
{
7+
public const ATMOSPHERIC_PRESSURE_UNIT = 'hPa';
8+
public const CLOUDINESS_UNIT = '%';
9+
public const HUMIDITY_UNIT = '%';
10+
public const POLLUTANT_CONCENTRATION_UNIT = 'μg/m3';
11+
public const PRECIPITATION_UNIT = 'mm';
12+
public const PRECIPITATION_PROBABILITY_UNIT = '%';
13+
public const SPEED_UNIT = 'm/s';
14+
public const TEMPERATURE_UNIT = '°C';
15+
public const VISIBILITY_UNIT = 'km';
16+
}

src/MeasurementSystem.php renamed to src/MeasurementSystem/MeasurementSystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace ProgrammatorDev\OpenWeatherMap;
3+
namespace ProgrammatorDev\OpenWeatherMap\MeasurementSystem;
44

55
class MeasurementSystem
66
{

src/MeasurementSystem/Standard.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace ProgrammatorDev\OpenWeatherMap\MeasurementSystem;
4+
5+
class Standard
6+
{
7+
public const ATMOSPHERIC_PRESSURE_UNIT = 'hPa';
8+
public const CLOUDINESS_UNIT = '%';
9+
public const HUMIDITY_UNIT = '%';
10+
public const POLLUTANT_CONCENTRATION_UNIT = 'μg/m3';
11+
public const PRECIPITATION_UNIT = 'mm';
12+
public const PRECIPITATION_PROBABILITY_UNIT = '%';
13+
public const SPEED_UNIT = 'm/s';
14+
public const TEMPERATURE_UNIT = 'K';
15+
public const VISIBILITY_UNIT = 'km';
16+
}

0 commit comments

Comments
 (0)