Skip to content

Commit 3c6232d

Browse files
committed
Use strict comparison
1 parent 486866a commit 3c6232d

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/Services/MaxMindDatabase.php

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

55
namespace InteractionDesignFoundation\GeoIP\Services;
66

7-
use PharData;
8-
use Exception;
97
use GeoIp2\Database\Reader;
108

119
class MaxMindDatabase extends AbstractService
@@ -25,6 +23,7 @@ class MaxMindDatabase extends AbstractService
2523
public function boot()
2624
{
2725
$path = $this->config('database_path');
26+
assert(is_string($path), 'Invalid "database_path" config value');
2827

2928
// Copy test database for now
3029
if (is_file($path) === false) {
@@ -65,20 +64,20 @@ public function locate($ip)
6564
* Update function for service.
6665
*
6766
* @return string
68-
* @throws Exception
67+
* @throws \Exception
6968
*/
7069
public function update()
7170
{
7271
if ($this->config('database_path', false) === false) {
73-
throw new Exception('Database path not set in config file.');
72+
throw new \Exception('Database path not set in config file.');
7473
}
7574

7675
$this->withTemporaryDirectory(function ($directory) {
7776
$tarFile = sprintf('%s/maxmind.tar.gz', $directory);
7877

7978
file_put_contents($tarFile, fopen($this->config('update_url'), 'rb'));
8079

81-
$archive = new PharData($tarFile);
80+
$archive = new \PharData($tarFile);
8281

8382
$file = $this->findDatabaseFile($archive);
8483

@@ -93,8 +92,8 @@ public function update()
9392
}
9493

9594
/**
96-
* Provide a temporary directory to perform operations in and and ensure
97-
* it is removed afterwards.
95+
* Provide a temporary directory to perform operations in
96+
* and ensure it is removed afterward.
9897
*
9998
* @param callable $callback
10099
*
@@ -131,15 +130,15 @@ protected function findDatabaseFile($archive)
131130
{
132131
foreach ($archive as $file) {
133132
if ($file->isDir()) {
134-
return $this->findDatabaseFile(new PharData($file->getPathName()));
133+
return $this->findDatabaseFile(new \PharData($file->getPathName()));
135134
}
136135

137136
if (pathinfo($file, \PATHINFO_EXTENSION) === 'mmdb') {
138137
return $file;
139138
}
140139
}
141140

142-
throw new Exception('Database file could not be found within archive.');
141+
throw new \Exception('Database file could not be found within archive.');
143142
}
144143

145144
/**
@@ -160,7 +159,7 @@ protected function deleteDirectory(string $directory)
160159
}
161160

162161
foreach (scandir($directory) as $item) {
163-
if ($item == '.' || $item == '..') {
162+
if ($item === '.' || $item === '..') {
164163
continue;
165164
}
166165

0 commit comments

Comments
 (0)