mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-12 01:54:41 +08:00
Fixed all possible PHPStan errors
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Shlinkio\Shlink\Common\Exception;
|
||||
|
||||
class WrongIpException extends RuntimeException
|
||||
{
|
||||
public static function fromIpAddress($ipAddress, \Exception $prev = null)
|
||||
public static function fromIpAddress($ipAddress, \Throwable $prev = null)
|
||||
{
|
||||
return new self(sprintf('Provided IP "%s" is invalid', $ipAddress), 0, $prev);
|
||||
}
|
||||
|
||||
@@ -22,15 +22,17 @@ class IpLocationResolver implements IpLocationResolverInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $ipAddress
|
||||
* @param string $ipAddress
|
||||
* @return array
|
||||
* @throws WrongIpException
|
||||
*/
|
||||
public function resolveIpLocation($ipAddress)
|
||||
public function resolveIpLocation(string $ipAddress): array
|
||||
{
|
||||
try {
|
||||
$response = $this->httpClient->get(sprintf(self::SERVICE_PATTERN, $ipAddress));
|
||||
return json_decode((string) $response->getBody(), true);
|
||||
} catch (GuzzleException $e) {
|
||||
/** @var \Throwable $e */
|
||||
throw WrongIpException::fromIpAddress($ipAddress, $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common\Service;
|
||||
|
||||
use Shlinkio\Shlink\Common\Exception\WrongIpException;
|
||||
|
||||
interface IpLocationResolverInterface
|
||||
{
|
||||
/**
|
||||
* @param $ipAddress
|
||||
* @param string $ipAddress
|
||||
* @return array
|
||||
* @throws WrongIpException
|
||||
*/
|
||||
public function resolveIpLocation($ipAddress);
|
||||
public function resolveIpLocation(string $ipAddress): array;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ namespace Shlinkio\Shlink\Common\Util;
|
||||
class DateRange
|
||||
{
|
||||
/**
|
||||
* @var \DateTimeInterface
|
||||
* @var \DateTimeInterface|null
|
||||
*/
|
||||
private $startDate;
|
||||
/**
|
||||
* @var \DateTimeInterface
|
||||
* @var \DateTimeInterface|null
|
||||
*/
|
||||
private $endDate;
|
||||
|
||||
@@ -21,7 +21,7 @@ class DateRange
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTimeInterface
|
||||
* @return \DateTimeInterface|null
|
||||
*/
|
||||
public function getStartDate()
|
||||
{
|
||||
@@ -29,7 +29,7 @@ class DateRange
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTimeInterface
|
||||
* @return \DateTimeInterface|null
|
||||
*/
|
||||
public function getEndDate()
|
||||
{
|
||||
@@ -39,8 +39,8 @@ class DateRange
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty()
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return is_null($this->startDate) && is_null($this->endDate);
|
||||
return $this->startDate === null && $this->endDate === null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user