Skip to content

Commit ff4d9b3

Browse files
committed
Move the currencies include inside the method using is
1 parent dee7ab6 commit ff4d9b3

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/GeoIP.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class GeoIP
7575
/**
7676
* Create a new GeoIP instance.
7777
*
78-
* @param array $config
78+
* @param array $config
7979
*/
8080
public function __construct(array $config)
8181
{
@@ -87,11 +87,6 @@ public function __construct(array $config)
8787
$this->config('default_location', [])
8888
);
8989

90-
// Include currencies
91-
if ($this->config('include_currency', false)) {
92-
$this->currencies = include(__DIR__ . '/Support/Currencies.php');
93-
}
94-
9590
// Set IP
9691
$this->remote_ip = $this->default_location['ip'] = $this->getClientIP();
9792
}
@@ -101,7 +96,7 @@ public function __construct(array $config)
10196
*
10297
* @param string $ip
10398
*
104-
* @return array
99+
* @return \Torann\GeoIP\Location
105100
*/
106101
public function getLocation($ip = null)
107102
{
@@ -121,7 +116,7 @@ public function getLocation($ip = null)
121116
*
122117
* @param string $ip
123118
*
124-
* @return array
119+
* @return \Torann\GeoIP\Location
125120
* @throws \Exception
126121
*/
127122
private function find($ip = null)
@@ -173,6 +168,10 @@ private function find($ip = null)
173168
*/
174169
public function getCurrency($iso)
175170
{
171+
if ($this->currencies === null && $this->config('include_currency', false)) {
172+
$this->currencies = include(__DIR__ . '/Support/Currencies.php');
173+
}
174+
176175
return Arr::get($this->currencies, $iso);
177176
}
178177

0 commit comments

Comments
 (0)