Skip to content

Commit 57acec1

Browse files
committed
Improved service provider
1 parent 5cc509f commit 57acec1

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 2.2.2 (released 2016-01-30)
4+
5+
- Improved service provider
6+
37
## 2.2.1 (released 2016-01-17)
48

59
- Lumen 5.2 support

src/HashidsServiceProvider.php

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Vinkla\Hashids;
1313

1414
use Hashids\Hashids;
15-
use Illuminate\Contracts\Container\Container as Application;
15+
use Illuminate\Contracts\Container\Container;
1616
use Illuminate\Foundation\Application as LaravelApplication;
1717
use Illuminate\Support\ServiceProvider;
1818
use Laravel\Lumen\Application as LumenApplication;
@@ -59,62 +59,56 @@ protected function setupConfig()
5959
*/
6060
public function register()
6161
{
62-
$this->registerFactory($this->app);
63-
$this->registerManager($this->app);
64-
$this->registerBindings($this->app);
62+
$this->registerFactory();
63+
$this->registerManager();
64+
$this->registerBindings();
6565
}
6666

6767
/**
6868
* Register the factory class.
6969
*
70-
* @param \Illuminate\Contracts\Container\Container $app
71-
*
7270
* @return void
7371
*/
74-
protected function registerFactory(Application $app)
72+
protected function registerFactory()
7573
{
76-
$app->singleton('hashids.factory', function () {
74+
$this->app->singleton('hashids.factory', function () {
7775
return new HashidsFactory();
7876
});
7977

80-
$app->alias('hashids.factory', HashidsFactory::class);
78+
$this->app->alias('hashids.factory', HashidsFactory::class);
8179
}
8280

8381
/**
8482
* Register the manager class.
8583
*
86-
* @param \Illuminate\Contracts\Container\Container $app
87-
*
8884
* @return void
8985
*/
90-
protected function registerManager(Application $app)
86+
protected function registerManager()
9187
{
92-
$app->singleton('hashids', function ($app) {
88+
$this->app->singleton('hashids', function (Container $app) {
9389
$config = $app['config'];
9490
$factory = $app['hashids.factory'];
9591

9692
return new HashidsManager($config, $factory);
9793
});
9894

99-
$app->alias('hashids', HashidsManager::class);
95+
$this->app->alias('hashids', HashidsManager::class);
10096
}
10197

10298
/**
10399
* Register the bindings.
104100
*
105-
* @param \Illuminate\Contracts\Container\Container $app
106-
*
107101
* @return void
108102
*/
109-
protected function registerBindings(Application $app)
103+
protected function registerBindings()
110104
{
111-
$app->bind('hashids.connection', function ($app) {
105+
$this->app->bind('hashids.connection', function (Container $app) {
112106
$manager = $app['hashids'];
113107

114108
return $manager->connection();
115109
});
116110

117-
$app->alias('hashids.connection', Hashids::class);
111+
$this->app->alias('hashids.connection', Hashids::class);
118112
}
119113

120114
/**

0 commit comments

Comments
 (0)