Skip to content

Commit

Permalink
Merge pull request #23 from ARCANEDEV/patch-service_providers
Browse files Browse the repository at this point in the history
Updating service providers
  • Loading branch information
arcanedev-maroc authored Dec 19, 2016
2 parents 2fc2cce + eef3b52 commit caf24ea
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 38 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"license": "MIT",
"require": {
"php": ">=5.6",
"arcanedev/support": "~3.0"
"arcanedev/support": "~3.20"
},
"require-dev": {
"phpunit/phpcov": "~2.0|~3.0",
"phpunit/phpunit": "~4.0|~5.0"
"phpunit/phpcov": "~3.0",
"phpunit/phpunit": "~5.0"
},
"autoload": {
"psr-4": {
Expand Down
28 changes: 10 additions & 18 deletions src/Providers/UtilityServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Arcanedev\SeoHelper\Providers;

use Arcanedev\SeoHelper\Contracts;
use Arcanedev\SeoHelper\SeoMeta;
use Arcanedev\SeoHelper\SeoOpenGraph;
use Arcanedev\SeoHelper\SeoTwitter;
Expand Down Expand Up @@ -51,9 +52,9 @@ public function provides()
'arcanedev.seo-helper.meta',
'arcanedev.seo-helper.open-graph',
'arcanedev.seo-helper.twitter',
\Arcanedev\SeoHelper\Contracts\SeoMeta::class,
\Arcanedev\SeoHelper\Contracts\SeoOpenGraph::class,
\Arcanedev\SeoHelper\Contracts\SeoTwitter::class,
Contracts\SeoMeta::class,
Contracts\SeoOpenGraph::class,
Contracts\SeoTwitter::class,
];
}

Expand All @@ -66,52 +67,43 @@ public function provides()
*/
private function registerSeoMetaService()
{
$this->singleton('arcanedev.seo-helper.meta', function ($app) {
$this->singleton(Contracts\SeoMeta::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];

return new SeoMeta($config->get('seo-helper'));
});

$this->bind(
\Arcanedev\SeoHelper\Contracts\SeoMeta::class,
'arcanedev.seo-helper.meta'
);
$this->singleton('arcanedev.seo-helper.meta', Contracts\SeoMeta::class);
}

/**
* Register SeoOpenGraph service.
*/
private function registerSeoOpenGraphService()
{
$this->singleton('arcanedev.seo-helper.open-graph', function ($app) {
$this->singleton(Contracts\SeoOpenGraph::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];

return new SeoOpenGraph($config->get('seo-helper'));
});

$this->bind(
\Arcanedev\SeoHelper\Contracts\SeoOpenGraph::class,
'arcanedev.seo-helper.open-graph'
);
$this->singleton('arcanedev.seo-helper.open-graph', Contracts\SeoOpenGraph::class);
}

/**
* Register SeoTwitter service.
*/
private function registerSeoTwitterService()
{
$this->singleton('arcanedev.seo-helper.twitter', function ($app) {
$this->singleton(Contracts\SeoTwitter::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];

return new SeoTwitter($config->get('seo-helper'));
});

$this->bind(
\Arcanedev\SeoHelper\Contracts\SeoTwitter::class,
'arcanedev.seo-helper.twitter'
);
$this->singleton('arcanedev.seo-helper.twitter', Contracts\SeoTwitter::class);
}
}
10 changes: 1 addition & 9 deletions src/SeoHelperServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getBasePath()
public function register()
{
$this->registerConfig();
$this->app->register(Providers\UtilityServiceProvider::class);
$this->registerProvider(Providers\UtilityServiceProvider::class);
$this->registerSeoHelperService();
}

Expand All @@ -76,14 +76,6 @@ public function provides()
return [
'arcanedev.seo-helper',
Contracts\SeoHelper::class,

// Utilities
'arcanedev.seo-helper.meta',
'arcanedev.seo-helper.open-graph',
'arcanedev.seo-helper.twitter',
Contracts\SeoMeta::class,
Contracts\SeoOpenGraph::class,
Contracts\SeoTwitter::class,
];
}

Expand Down
8 changes: 0 additions & 8 deletions tests/SeoHelperServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ public function it_can_provides()
$expected = [
'arcanedev.seo-helper',
\Arcanedev\SeoHelper\Contracts\SeoHelper::class,

// Utilities
'arcanedev.seo-helper.meta',
'arcanedev.seo-helper.open-graph',
'arcanedev.seo-helper.twitter',
\Arcanedev\SeoHelper\Contracts\SeoMeta::class,
\Arcanedev\SeoHelper\Contracts\SeoOpenGraph::class,
\Arcanedev\SeoHelper\Contracts\SeoTwitter::class,
];

$this->assertSame($expected, $this->provider->provides());
Expand Down

0 comments on commit caf24ea

Please sign in to comment.