Skip to content

Commit

Permalink
Add PHP Coding Standards Fixer in CI (#1196)
Browse files Browse the repository at this point in the history
* Update composer.json

* Update .gitignore

* Update php.yml

* Apply PHPCSFixer fixes

* Switch to php-cs-fixer/shim

* Create .php-cs-fixer.dist.php
  • Loading branch information
jbelien committed Jul 21, 2023
1 parent d26447d commit d1442bc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 48 deletions.
21 changes: 0 additions & 21 deletions AbstractHostIp.php
Expand Up @@ -31,9 +31,6 @@ abstract protected function executeQuery(string $url): AddressCollection;

abstract protected function getEndpointURL(): string;

/**
* {@inheritdoc}
*/
public function geocodeQuery(GeocodeQuery $query): Collection
{
$address = $query->getText();
Expand All @@ -55,19 +52,11 @@ public function geocodeQuery(GeocodeQuery $query): Collection
return $this->executeQuery($url);
}

/**
* {@inheritdoc}
*/
public function reverseQuery(ReverseQuery $query): Collection
{
throw new UnsupportedOperation('The HostIp provider is not able to do reverse geocoding.');
}

/**
* @param array $data
*
* @return bool
*/
protected function isUnknownLocation(array $data): bool
{
return empty($data['lat'])
Expand All @@ -76,11 +65,6 @@ protected function isUnknownLocation(array $data): bool
&& '(Unknown Country?)' === $data['country_name'];
}

/**
* @param array $data
*
* @return bool
*/
protected function isPrivateLocation(array $data): bool
{
return empty($data['lat'])
Expand All @@ -89,11 +73,6 @@ protected function isPrivateLocation(array $data): bool
&& '(Private Address)' === $data['country_name'];
}

/**
* @param array $data
*
* @return AddressCollection
*/
protected function prepareAddressCollection(array $data): AddressCollection
{
// Return empty collection if address was not found
Expand Down
15 changes: 2 additions & 13 deletions HostIp.php
Expand Up @@ -12,9 +12,7 @@

namespace Geocoder\Provider\HostIp;

use Geocoder\Collection;
use Geocoder\Model\AddressCollection;
use function json_decode;

/**
* @author William Durand <william.durand1@gmail.com>
Expand All @@ -24,31 +22,22 @@ final class HostIp extends AbstractHostIp
/**
* @var string
*/
const ENDPOINT_URL = 'http://api.hostip.info/get_json.php?ip=%s&position=true';
public const ENDPOINT_URL = 'http://api.hostip.info/get_json.php?ip=%s&position=true';

/**
* {@inheritdoc}
*/
public function getName(): string
{
return 'host_ip';
}

/**
* @return string
*/
public function getEndpointURL(): string
{
return self::ENDPOINT_URL;
}

/**
* @param string $url
*/
protected function executeQuery(string $url): AddressCollection
{
$content = $this->getUrlContents($url);
$data = json_decode($content, true);
$data = \json_decode($content, true);

if (!$data) {
return new AddressCollection([]);
Expand Down
15 changes: 2 additions & 13 deletions HostIpXml.php
Expand Up @@ -12,9 +12,7 @@

namespace Geocoder\Provider\HostIp;

use Geocoder\Collection;
use Geocoder\Model\AddressCollection;
use function simplexml_load_string;

/**
* @author Oleg Andreyev <oleg@andreyev.lv>
Expand All @@ -24,31 +22,22 @@ final class HostIpXml extends AbstractHostIp
/**
* @var string
*/
const ENDPOINT_URL = 'http://api.hostip.info/get_xml.php?ip=%s&position=true';
public const ENDPOINT_URL = 'http://api.hostip.info/get_xml.php?ip=%s&position=true';

/**
* {@inheritdoc}
*/
public function getName(): string
{
return 'host_ip_xml';
}

/**
* @return string
*/
public function getEndpointURL(): string
{
return self::ENDPOINT_URL;
}

/**
* @param string $url
*/
protected function executeQuery(string $url): AddressCollection
{
$content = $this->getUrlContents($url);
$xml = simplexml_load_string($content);
$xml = \simplexml_load_string($content);

$hostIp = $xml->xpath('/HostipLookupResultSet/gml:featureMember/Hostip');
if (empty($hostIp[0])) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/HostIpTest.php
Expand Up @@ -14,9 +14,9 @@

use Geocoder\IntegrationTest\BaseTestCase;
use Geocoder\Location;
use Geocoder\Provider\HostIp\HostIp;
use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;
use Geocoder\Provider\HostIp\HostIp;

class HostIpTest extends BaseTestCase
{
Expand Down

0 comments on commit d1442bc

Please sign in to comment.