Skip to content

Commit

Permalink
Merge pull request #11 from ARCANEDEV/patch-1
Browse files Browse the repository at this point in the history
Updating the package
  • Loading branch information
arcanedev-maroc committed Feb 19, 2018
2 parents a0e1dee + 23c7629 commit 099689f
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 83 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
/vendor/
/composer.lock
/composer.phar
/phpunit.xml
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Expand Up @@ -22,7 +22,7 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 2
runs: 3
php_code_sniffer:
enabled: true
config:
Expand Down
6 changes: 2 additions & 4 deletions .travis.yml
Expand Up @@ -5,18 +5,16 @@ sudo: false
php:
- 7.0
- 7.1
- 7.2
- nightly

matrix:
allow_failures:
- php: nightly

env:
- TESTBENCH_VERSION=3.5.*

before_script:
- travis_retry composer self-update
- travis_retry composer require --prefer-source --no-interaction --dev "orchestra/testbench:${TESTBENCH_VERSION}"
- travis_retry composer install --prefer-source --no-interaction

script:
- composer validate
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2017 ARCANEDEV <arcanedev.maroc@gmail.com> - GeoIP
Copyright (c) 2015-2018 ARCANEDEV <arcanedev.maroc@gmail.com> - GeoIP

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 6 additions & 11 deletions composer.json
Expand Up @@ -14,13 +14,14 @@
],
"require": {
"php": ">=7.0",
"arcanedev/support": "~4.2",
"arcanedev/support": "~4.2.0",
"guzzlehttp/guzzle": "~6.0"
},
"require-dev": {
"phpunit/phpcov": "~4.0",
"phpunit/phpunit": "~6.0",
"geoip2/geoip2": "~2.6"
"orchestra/testbench": "~3.5.0",
"phpunit/phpunit": "~6.0",
"phpunit/phpcov": "~4.0",
"geoip2/geoip2": "~2.6"
},
"autoload": {
"psr-4": {
Expand All @@ -36,16 +37,10 @@
"laravel": {
"providers": [
"Arcanedev\\GeoIP\\GeoIPServiceProvider"
],
"aliases": {
"GeoIP": "Arcanedev\\GeoIP\\Facades\\GeoIP"
}
]
}
},
"suggest": {
"geoip2/geoip2": "Required if you're going to use the MaxMind database or web service."
},
"scripts": {
"testbench": "composer require --dev \"orchestra/testbench=~3.5.0\""
}
}
37 changes: 23 additions & 14 deletions config/geoip.php
@@ -1,17 +1,20 @@
<?php

return [
/* ------------------------------------------------------------------------------------------------

/* -----------------------------------------------------------------
| Default Driver
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
| Supported: 'freegeoip', 'ip-api', 'maxmind-database', 'maxmind-api'
*/

'default' => 'freegeoip',

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Supported Drivers
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'supported' => [
'freegeoip' => [
'driver' => Arcanedev\GeoIP\Drivers\FreeGeoIpDriver::class,
Expand Down Expand Up @@ -47,10 +50,11 @@
],
],

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Cache
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'cache' => [
'mode' => 'all',

Expand All @@ -59,20 +63,22 @@
'expires' => 30,
],

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Log failures
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'log-failures' => [
'enabled' => true,

'location' => storage_path('logs/geoip.log'),
],

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Entities
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'location' => [
'default' => [
'ip' => '',
Expand All @@ -90,10 +96,11 @@
],
],

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Continents
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'continents' => [
'A1' => '--',
'A2' => '--',
Expand Down Expand Up @@ -349,10 +356,11 @@
'ZW' => 'AF',
],

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Currencies
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'currencies' => [
'included' => true,

Expand Down Expand Up @@ -606,4 +614,5 @@
'ZW' => 'ZWL',
],
],

];
6 changes: 3 additions & 3 deletions tests/DriverManagerTest.php
Expand Up @@ -50,14 +50,14 @@ public function it_can_be_instantiated()
];

foreach ($expectations as $expected) {
$this->assertInstanceOf($expected, $this->manager);
static::assertInstanceOf($expected, $this->manager);
}
}

/** @test */
public function it_can_get_default_driver()
{
$this->assertInstanceOf(
static::assertInstanceOf(
\Arcanedev\GeoIP\Drivers\FreeGeoIpDriver::class,
$this->manager->driver()
);
Expand All @@ -74,7 +74,7 @@ public function it_can_get_driver_by_name()
];

foreach ($drivers as $name => $driver) {
$this->assertInstanceOf($driver, $this->manager->driver($name));
static::assertInstanceOf($driver, $this->manager->driver($name));
}
}
}
12 changes: 6 additions & 6 deletions tests/Drivers/FreeGeoIpDriverTest.php
Expand Up @@ -53,7 +53,7 @@ public function it_can_be_instantiated()
];

foreach ($expectations as $expected) {
$this->assertInstanceOf($expected, $this->driver);
static::assertInstanceOf($expected, $this->driver);
}
}

Expand All @@ -62,7 +62,7 @@ public function it_can_locate()
{
$location = $this->driver->locate('128.101.101.101');

$this->assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location);
static::assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location);

$expected = [
'ip' => '128.101.101.101',
Expand All @@ -78,10 +78,10 @@ public function it_can_locate()
'continent' => 'NA',
];

$this->assertSame($expected, $location->attributes());
$this->assertSame($expected, $location->toArray());
static::assertSame($expected, $location->attributes());
static::assertSame($expected, $location->toArray());

$this->assertFalse($location->default);
$this->assertSame($expected['city'].', '.$expected['state_code'], $location->display_name);
static::assertFalse($location->default);
static::assertSame($expected['city'].', '.$expected['state_code'], $location->display_name);
}
}
20 changes: 10 additions & 10 deletions tests/Drivers/IpApiDriverTest.php
Expand Up @@ -53,7 +53,7 @@ public function it_can_be_instantiated()
];

foreach ($expectations as $expected) {
$this->assertInstanceOf($expected, $this->driver);
static::assertInstanceOf($expected, $this->driver);
}
}

Expand All @@ -62,26 +62,26 @@ public function it_can_locate()
{
$location = $this->driver->locate('128.101.101.101');

$this->assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location);
static::assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location);

$expected = [
'ip' => '128.101.101.101',
'iso_code' => 'US',
'country' => 'United States',
'city' => 'Minneapolis',
'city' => 'Saint Paul',
'state' => 'Minnesota',
'state_code' => 'MN',
'postal_code' => '55414',
'latitude' => 44.9759,
'longitude' => -93.2166,
'postal_code' => '55102',
'latitude' => 44.9278,
'longitude' => -93.1162,
'timezone' => 'America/Chicago',
'continent' => 'NA',
];

$this->assertSame($expected, $location->attributes());
$this->assertSame($expected, $location->toArray());
static::assertSame($expected, $location->attributes());
static::assertSame($expected, $location->toArray());

$this->assertFalse($location->default);
$this->assertSame($expected['city'].', '.$expected['state_code'], $location->display_name);
static::assertFalse($location->default);
static::assertSame($expected['city'].', '.$expected['state_code'], $location->display_name);
}
}
12 changes: 6 additions & 6 deletions tests/Drivers/MaxmindDatabaseDriverTest.php
Expand Up @@ -18,7 +18,7 @@ class MaxmindDatabaseDriverTest extends TestCase
/** @test */
public function it_can_be_instantiated()
{
$this->assertInstanceOf(
static::assertInstanceOf(
\Arcanedev\GeoIP\Drivers\MaxmindDatabaseDriver::class,
$this->makeDriver()
);
Expand All @@ -31,7 +31,7 @@ public function it_can_locate()

$location = $this->makeDriver()->locate('128.101.101.101');

$this->assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location);
static::assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location);

$expected = [
'ip' => '128.101.101.101',
Expand All @@ -47,11 +47,11 @@ public function it_can_locate()
'continent' => 'NA',
];

$this->assertSame($expected, $location->attributes());
$this->assertSame($expected, $location->toArray());
static::assertSame($expected, $location->attributes());
static::assertSame($expected, $location->toArray());

$this->assertFalse($location->default);
$this->assertSame($expected['city'].', '.$expected['state_code'], $location->display_name);
static::assertFalse($location->default);
static::assertSame($expected['city'].', '.$expected['state_code'], $location->display_name);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/Entities/ContinentsTest.php
Expand Up @@ -52,11 +52,11 @@ public function it_can_be_instantiated()
];

foreach ($expectations as $expected) {
$this->assertInstanceOf($expected, $this->continents);
static::assertInstanceOf($expected, $this->continents);
}

$this->assertFalse($this->continents->isEmpty());
$this->assertCount(252, $this->continents);
static::assertFalse($this->continents->isEmpty());
static::assertCount(252, $this->continents);
}

/** @test */
Expand All @@ -70,10 +70,10 @@ public function it_can_get_continent()
];

foreach ($expectations as $key => $expected) {
$this->assertSame($expected, $this->continents->get($key));
static::assertSame($expected, $this->continents->get($key));
}

$this->assertNull($this->continents->get('ZZ'));
$this->assertSame('Unknown', $this->continents->get('ZZ', 'Unknown'));
static::assertNull($this->continents->get('ZZ'));
static::assertSame('Unknown', $this->continents->get('ZZ', 'Unknown'));
}
}
12 changes: 6 additions & 6 deletions tests/Entities/CurrenciesTest.php
Expand Up @@ -51,11 +51,11 @@ public function it_can_be_instantiated()
];

foreach ($expectations as $expected) {
$this->assertInstanceOf($expected, $this->currencies);
static::assertInstanceOf($expected, $this->currencies);
}

$this->assertFalse($this->currencies->isEmpty());
$this->assertCount(247, $this->currencies);
static::assertFalse($this->currencies->isEmpty());
static::assertCount(247, $this->currencies);
}

/** @test */
Expand All @@ -68,10 +68,10 @@ public function it_can_get_continent()
];

foreach ($expectations as $key => $expected) {
$this->assertSame($expected, $this->currencies->get($key));
static::assertSame($expected, $this->currencies->get($key));
}

$this->assertNull($this->currencies->get('ZZ'));
$this->assertSame('Unknown', $this->currencies->get('ZZ', 'Unknown'));
static::assertNull($this->currencies->get('ZZ'));
static::assertSame('Unknown', $this->currencies->get('ZZ', 'Unknown'));
}
}
4 changes: 2 additions & 2 deletions tests/GeoIPServiceProviderTest.php
Expand Up @@ -51,7 +51,7 @@ public function it_can_be_instantiated()
];

foreach ($expectations as $expected) {
$this->assertInstanceOf($expected, $this->provider);
static::assertInstanceOf($expected, $this->provider);
}
}

Expand All @@ -66,6 +66,6 @@ public function it_can_provides()
\Arcanedev\GeoIP\Contracts\DriverFactory::class,
];

$this->assertSame($expected, $this->provider->provides());
static::assertSame($expected, $this->provider->provides());
}
}

0 comments on commit 099689f

Please sign in to comment.