Skip to content

Commit 05a995c

Browse files
committed
Remove deprecated constructor and methods
1 parent 8a9b87f commit 05a995c

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

Cmfcmf/OpenWeatherMap.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class OpenWeatherMap
101101
/**
102102
* Constructs the OpenWeatherMap object.
103103
*
104-
* @param string $apiKey The OpenWeatherMap API key. Required and only optional for BC.
104+
* @param string $apiKey The OpenWeatherMap API key. Required.
105105
* @param null|FetcherInterface $fetcher The interface to fetch the data from OpenWeatherMap. Defaults to
106106
* CurlFetcher() if cURL is available. Otherwise defaults to
107107
* FileGetContentsFetcher() using 'file_get_contents()'.
@@ -113,17 +113,14 @@ class OpenWeatherMap
113113
*
114114
* @api
115115
*/
116-
public function __construct($apiKey = '', $fetcher = null, $cache = false, $seconds = 600)
116+
public function __construct($apiKey, $fetcher = null, $cache = false, $seconds = 600)
117117
{
118118
if (!is_string($apiKey) || empty($apiKey)) {
119-
// BC
120-
$seconds = $cache !== false ? $cache : 600;
121-
$cache = $fetcher !== null ? $fetcher : false;
122-
$fetcher = $apiKey !== '' ? $apiKey : null;
123-
} else {
124-
$this->apiKey = $apiKey;
119+
throw new \InvalidArgumentException("You must provide an API key.");
125120
}
126121

122+
$this->apiKey = $apiKey;
123+
127124
if ($cache !== false && !($cache instanceof AbstractCache)) {
128125
throw new \InvalidArgumentException('The cache class must implement the FetcherInterface!');
129126
}
@@ -554,14 +551,6 @@ public function wasCached()
554551
return $this->wasCached;
555552
}
556553

557-
/**
558-
* @deprecated Use {@link self::getRawWeatherData()} instead.
559-
*/
560-
public function getRawData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml')
561-
{
562-
return $this->getRawWeatherData($query, $units, $lang, $appid, $mode);
563-
}
564-
565554
/**
566555
* Fetches the result or delivers a cached version of the result.
567556
*

tests/OpenWeatherMapTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,6 @@ protected function tearDown()
6161
@rmdir(__DIR__.'/temps');
6262
}
6363

64-
public function testApiKeyIsEmpty()
65-
{
66-
$expectApiKey = '';
67-
$weather = new OpenWeatherMap($expectApiKey, null, false, 600);
68-
$apiKey = $weather->getApiKey();
69-
70-
$this->assertSame($expectApiKey, $apiKey);
71-
}
72-
7364
public function testApiKeyNotNull()
7465
{
7566
$weather = $this->owm;

0 commit comments

Comments
 (0)