Skip to content

Commit 7c0addd

Browse files
committed
refactor for laravel 5
1 parent 5b5089d commit 7c0addd

11 files changed

+58
-65
lines changed

.travis.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
language: php
22

33
php:
4-
- 5.3
54
- 5.4
65
- 5.5
6+
- 5.6
7+
- hhvm
78

89
before_script:
9-
- curl -sS http://getcomposer.org/installer | php
10-
- php composer.phar install --dev --prefer-dist --no-interaction
10+
- travis_retry composer self-update
11+
- travis_retry composer install --no-interaction --prefer-source --dev
1112

1213
script: phpunit --coverage-text --coverage-clover ./build/logs/clover.xml
1314

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2013 Antoine Corcy <contact@sbin.dk>
1+
Copyright (c) 2013-2015 Antoine Corcy <contact@sbin.dk>
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

composer.json

+13-6
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,26 @@
1313
}],
1414

1515
"require" : {
16-
"php" : ">=5.3.0",
17-
"illuminate/support" : "~4.0",
16+
"php" : ">=5.4",
17+
"illuminate/support" : "5.0.*",
1818
"willdurand/geocoder" : "~2.4"
1919
},
2020

2121
"require-dev" : {
22-
"orchestra/testbench" : "~2.0",
23-
"satooshi/php-coveralls" : "~0.6"
22+
"orchestra/testbench" : "~3.0",
23+
"satooshi/php-coveralls" : "~0.6",
24+
"phpunit/phpunit" : "~4.5"
2425
},
2526

2627
"autoload" : {
27-
"psr-0" : {
28-
"Toin0u\\Geocoder" : "src/"
28+
"psr-4" : {
29+
"Toin0u\\Geocoder\\" : "src/"
30+
}
31+
},
32+
33+
"autoload-dev" : {
34+
"psr-4": {
35+
"Toin0u\\Tests\\Geocoder\\" : "tests/"
2936
}
3037
},
3138

src/config/config.php renamed to config/geocoder.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
return array(
12+
return [
1313
// Providers get called in the chain order given here.
1414
// The first one to return a result will be used.
15-
'providers' => array(
16-
'Geocoder\Provider\GoogleMapsProvider' => array('fr-FR', 'Île-de-France', true),
15+
'providers' => [
16+
'Geocoder\Provider\GoogleMapsProvider' => ['fr-FR', 'Île-de-France', true],
1717
'Geocoder\Provider\FreeGeoIpProvider' => null,
18-
),
19-
'adapter' => 'Geocoder\HttpAdapter\CurlHttpAdapter'
20-
);
18+
],
19+
'adapter' => 'Geocoder\HttpAdapter\CurlHttpAdapter',
20+
];

phpunit.xml.dist

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
processIsolation="false"
99
stopOnFailure="false"
1010
syntaxCheck="false"
11-
bootstrap="tests/bootstrap.php"
11+
bootstrap="vendor/autoload.php"
1212
>
1313
<testsuites>
14-
<testsuite name="Geocoder library for Laravel4 Test Suite">
14+
<testsuite name="Geocoder library for Laravel Test Suite">
1515
<directory>./tests/</directory>
1616
</testsuite>
1717
</testsuites>
1818
<filter>
1919
<whitelist>
20-
<directory>./src/Toin0u/</directory>
20+
<directory>./src/</directory>
2121
</whitelist>
2222
</filter>
2323
</phpunit>

src/Toin0u/Geocoder/GeocoderFacade.php renamed to src/Facade/Geocoder.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Toin0u\Geocoder;
13-
14-
use Illuminate\Support\Facades\Facade;
12+
namespace Toin0u\Geocoder\Facade;
1513

1614
/**
1715
* Facade for Geocoder
1816
*
1917
* @author Antoine Corcy <contact@sbin.dk>
2018
*/
21-
class GeocoderFacade extends Facade
19+
class Geocoder extends \Illuminate\Support\Facades\Facade
2220
{
2321
/**
2422
* Get the registered name of the component.

src/Toin0u/Geocoder/GeocoderServiceProvider.php renamed to src/GeocoderServiceProvider.php

+10-14
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,26 @@
1313

1414
use Geocoder\Geocoder;
1515
use Geocoder\Provider\ChainProvider;
16-
use Illuminate\Support\ServiceProvider;
1716

1817
/**
1918
* Geocoder service provider
2019
*
2120
* @author Antoine Corcy <contact@sbin.dk>
2221
*/
23-
class GeocoderServiceProvider extends ServiceProvider
22+
class GeocoderServiceProvider extends \Illuminate\Support\ServiceProvider
2423
{
25-
/**
26-
* Indicates if loading of the provider is deferred.
27-
*
28-
* @var bool
29-
*/
30-
protected $defer = false;
31-
3224
/**
3325
* Bootstrap the application events.
3426
*
3527
* @return void
3628
*/
3729
public function boot()
3830
{
39-
$this->package('toin0u/geocoder-laravel');
31+
$source = realpath(__DIR__ . '/../config/geocoder.php');
32+
33+
$this->publishes([$source => config_path('geocoder.php')]);
34+
35+
$this->mergeConfigFrom($source, 'geocoder');
4036
}
4137

4238
/**
@@ -47,15 +43,15 @@ public function boot()
4743
public function register()
4844
{
4945
$this->app->singleton('geocoder.adapter', function($app) {
50-
$adapter = $app['config']->get('geocoder-laravel::adapter');
46+
$adapter = $app['config']->get('geocoder.adapter');
5147

5248
return new $adapter;
5349
});
5450

5551
$this->app->singleton('geocoder.chain', function($app) {
56-
$providers = array();
52+
$providers = [];
5753

58-
foreach($app['config']->get('geocoder-laravel::providers') as $provider => $arguments) {
54+
foreach($app['config']->get('geocoder.providers') as $provider => $arguments) {
5955
if (0 !== count($arguments)) {
6056
$providers[] = call_user_func_array(
6157
function ($arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null) use ($app, $provider) {
@@ -88,6 +84,6 @@ function ($arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null) use ($app, $pr
8884
*/
8985
public function provides()
9086
{
91-
return array('geocoder', 'geocoder.adapter', 'geocoder.chain');
87+
return ['geocoder', 'geocoder.adapter', 'geocoder.chain'];
9288
}
9389
}

tests/Geocoder/Tests/GeocoderFacadeTest.php renamed to tests/Facade/GeocoderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Geocoder\Tests;
12+
namespace Toin0u\Tests\Geocoder\Facade;
1313

1414
/**
1515
* @author Antoine Corcy <contact@sbin.dk>
1616
*/
17-
class GeocoderFacadeTest extends TestCase
17+
class GeocoderTest extends \Toin0u\Tests\Geocoder\TestCase
1818
{
1919
public function testGeocoderFacade()
2020
{

tests/Geocoder/Tests/GeocoderServiceProviderTest.php renamed to tests/GeocoderServiceProviderTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Geocoder\Tests;
12+
namespace Toin0u\Tests\Geocoder;
1313

1414
/**
1515
* @author Antoine Corcy <contact@sbin.dk>
@@ -18,11 +18,11 @@ class GeocoderServiceProviderTest extends TestCase
1818
{
1919
public function testConfig()
2020
{
21-
$this->assertTrue(is_array($providers = $this->app['config']->get('geocoder-laravel::providers')));
21+
$this->assertTrue(is_array($providers = $this->app['config']->get('geocoder.providers')));
2222
$this->assertCount(2, $providers);
2323
$this->assertArrayHasKey('Geocoder\\Provider\\GoogleMapsProvider', $providers);
2424
$this->assertArrayHasKey('Geocoder\\Provider\\FreeGeoIpProvider', $providers);
25-
$this->assertSame('Geocoder\\HttpAdapter\\CurlHttpAdapter', $this->app['config']->get('geocoder-laravel::adapter'));
25+
$this->assertSame('Geocoder\\HttpAdapter\\CurlHttpAdapter', $this->app['config']->get('geocoder.adapter'));
2626
}
2727

2828
public function testLoadedProviders()

tests/Geocoder/Tests/TestCase.php renamed to tests/TestCase.php

+14-8
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,30 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Geocoder\Tests;
12+
namespace Toin0u\Tests\Geocoder;
1313

1414
/**
1515
* @author Antoine Corcy <contact@sbin.dk>
1616
*/
1717
class TestCase extends \Orchestra\Testbench\TestCase
1818
{
19-
protected function getPackageProviders()
19+
/**
20+
* {@inheritDoc}
21+
*/
22+
protected function getPackageProviders($app)
2023
{
21-
return array(
24+
return [
2225
'Toin0u\Geocoder\GeocoderServiceProvider',
23-
);
26+
];
2427
}
2528

26-
protected function getPackageAliases()
29+
/**
30+
* {@inheritDoc}
31+
*/
32+
protected function getPackageAliases($app)
2733
{
28-
return array(
29-
'Geocoder' => 'Toin0u\Geocoder\GeocoderFacade',
30-
);
34+
return [
35+
'Geocoder' => 'Toin0u\Geocoder\Facade\Geocoder',
36+
];
3137
}
3238
}

tests/bootstrap.php

-15
This file was deleted.

0 commit comments

Comments
 (0)