Skip to content

Commit 7623666

Browse files
authored
Merge pull request #77 from cloudcreativity/remove-deprecations
fix: remove dynamic property deprecation notices
2 parents 92250d2 + 14a0792 commit 7623666

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/ipinfolaravel.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,28 @@ class ipinfolaravel
2323

2424
/**
2525
* Return true to skip IPinfo lookup, otherwise return false.
26-
* @var function
26+
* @var callable|null
2727
*/
2828
public $filter = null;
2929

3030
/**
31-
* Provides ip.
31+
* IP Handler interface instance.
3232
* @var ipinfo\ipinfolaravel\iphandler\IPHandlerInterface
3333
*/
3434
public $ip_selector = null;
3535

36+
/**
37+
* IPinfo client object.
38+
* @var IPinfoClient
39+
*/
40+
public $ipinfo = null;
41+
42+
/**
43+
* Boolean flag to handle exceptions.
44+
* @var bool
45+
*/
46+
public $no_except = false;
47+
3648
const CACHE_MAXSIZE = 4096;
3749
const CACHE_TTL = 60 * 24;
3850

@@ -50,15 +62,15 @@ public function handle($request, Closure $next)
5062
$details = null;
5163
} else {
5264
try {
53-
$details = $this->ipinfo->getDetails($this->ip_selector->getIP($request));
65+
$details = $this->ipinfo->getDetails($this->ip_selector->getIP($request));
5466
} catch (\Exception $e) {
5567
$details = null;
5668

5769
// users can't catch this exception with their own wrapper
5870
// middleware unfortunately, so we catch it for them. but for
5971
// backwards-compatibility, we throw the exception again unless
6072
// they've told us not to.
61-
if ($this->no_except != true) {
73+
if (!$this->no_except) {
6274
throw $e;
6375
}
6476
}

tests/IpinfolaravelTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ public function test_handle_skips_lookup_when_filter_returns_true()
9292

9393
public function test_handle_throws_if_client_throws_and_no_except_false()
9494
{
95-
$this->expectException(\Exception::class);
95+
$expected = new \RuntimeException('Boom! That went wrong.');
96+
97+
$this->expectExceptionObject($expected);
9698

9799
$client = $this->createMock(IPinfoClient::class);
98100
$client
99101
->method("getDetails")
100-
->willThrowException(new \Exception("fail"));
102+
->willThrowException($expected);
101103

102104
$selector = $this->createMock(IPHandlerInterface::class);
103105
$selector->method("getIP")->willReturn("1.2.3.4");

0 commit comments

Comments
 (0)