Skip to content

Commit 62b8037

Browse files
author
FabianHippmann
committed
run php-cs-fixer remove debug
1 parent 7696b80 commit 62b8037

File tree

6 files changed

+38
-41
lines changed

6 files changed

+38
-41
lines changed

config/snippet-manager.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
return array(
2+
3+
return [
34
/*
45
|--------------------------------------------------------------------------
56
| Routes group config
@@ -12,4 +13,4 @@
1213
'prefix' => 'snippets',
1314
'middleware' => 'auth',
1415
],
15-
);
16+
];

database/migrations/2017_07_28_162237_create_snippets_table.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
<?php
2-
use Illuminate\Database\Schema\Blueprint;
2+
33
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
45

5-
class CreateSnippetsTable extends Migration {
6+
class CreateSnippetsTable extends Migration
7+
{
68
/**
79
* Run the migrations.
8-
*
9-
* @return void
1010
*/
1111
public function up()
1212
{
13-
Schema::create('ms_snippets', function(Blueprint $table)
14-
{
13+
Schema::create('ms_snippets', function (Blueprint $table) {
1514
$table->increments('id');
1615
$table->string('locale');
1716
$table->string('namespace');
@@ -20,10 +19,9 @@ public function up()
2019
$table->timestamps();
2120
});
2221
}
22+
2323
/**
2424
* Reverse the migrations.
25-
*
26-
* @return void
2725
*/
2826
public function down()
2927
{

src/Controller.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22

33
namespace Moonshiner\SnippetManager;
44

5+
use Artisan;
6+
use Cache;
57
use Illuminate\Http\Request;
68
use Illuminate\Routing\Controller as BaseController;
7-
89
use Illuminate\Support\Collection;
910
use Moonshiner\SnippetManager\Models\Snippet;
10-
use Artisan;
11-
use App;
12-
use Cache;
1311

1412
class Controller extends BaseController
1513
{
16-
/** @var \Moonshiner\SnippetManager\SnippetManager */
14+
/** @var \Moonshiner\SnippetManager\SnippetManager */
1715
protected $manager;
16+
1817
public function __construct(SnippetManager $manager)
1918
{
2019
$this->manager = $manager;
@@ -24,6 +23,7 @@ public function getView()
2423
{
2524
return view('snippet-manager::index');
2625
}
26+
2727
public function index()
2828
{
2929
$allTranslations = Snippet::take(10)->get();
@@ -37,6 +37,7 @@ public function search()
3737

3838
return $allTranslations;
3939
}
40+
4041
public function groups()
4142
{
4243
$namespaces = Snippet::select('namespace')->distinct()->get();
@@ -48,14 +49,15 @@ public function groups()
4849
public function update(Request $request, Snippet $snippet)
4950
{
5051
$snippet->value = $request->input('value', '');
51-
$path = [$snippet->locale,$snippet->namespace, $snippet->key];
52+
$path = [$snippet->locale, $snippet->namespace, $snippet->key];
5253
$storeKey = implode('/', $path);
5354
Cache::flush($storeKey);
5455
Cache::put($storeKey, $snippet->value);
5556
$this->clearCache();
5657

5758
$snippet->save();
5859
}
60+
5961
protected function loadLocales()
6062
{
6163
//Set the default locale as the first one.
@@ -67,6 +69,7 @@ protected function loadLocales()
6769
$locales = $locales->all();
6870
}
6971
$locales = array_merge([config('app.locale')], $locales);
72+
7073
return array_unique($locales);
7174
}
7275

src/Models/Snippet.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
class Snippet extends Model
88
{
9-
109
protected $table = 'ms_snippets';
1110

12-
protected $guarded = array('id', 'created_at', 'updated_at');
13-
11+
protected $guarded = ['id', 'created_at', 'updated_at'];
1412
}

src/SnippetManager.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<?php
2+
23
namespace Moonshiner\SnippetManager;
34

4-
use Moonshiner\SnippetManager\Manager;
5-
use Illuminate\Foundation\Application;
6-
use Moonshiner\SnippetManager\Models\Snippet;
75
use Cache;
86
use DB;
7+
use Illuminate\Foundation\Application;
8+
use Moonshiner\SnippetManager\Models\Snippet;
99

10-
/**
11-
*
12-
*/
1310
class SnippetManager
1411
{
15-
private $namespace = "";
12+
private $namespace = '';
1613
protected $app;
14+
1715
public function __construct(Application $app)
1816
{
1917
$this->app = $app;
@@ -29,18 +27,18 @@ public function setNamespace($namespace)
2927

3028
public function get($key, $default = '', $namespace = null)
3129
{
32-
if ($namespace !== null) {
30+
if (null !== $namespace) {
3331
$this->namespace = $namespace;
3432
}
3533

3634
$path = [$this->app['config']['app.locale'], $this->namespace, $key];
3735
$storeKey = implode('/', $path);
3836
$manager = $this;
3937
$namespace = $this->namespace;
40-
xdebug_break();
4138
$snippet = Cache::rememberForever($storeKey, function () use ($namespace, $key, $default, $manager) {
4239
return $manager->fetch($namespace, $key, $default);
4340
});
41+
4442
return $snippet;
4543
}
4644

@@ -50,29 +48,32 @@ public function fetch($namespace, $key = null, $default = '')
5048
if ($key) {
5149
$query->where('key', $key);
5250
}
53-
if ($namespace != '') {
51+
if ('' != $namespace) {
5452
$query->where('namespace', $namespace);
5553
}
5654
$query->where('locale', $this->app['config']['app.locale']);
5755
if ($key) {
5856
$snippetValue = $query->pluck('value')->first();
59-
if (!$snippetValue) {
57+
if (! $snippetValue) {
6058
return $this->missingSnippet($namespace, $key, $default);
6159
}
60+
6261
return $snippetValue;
6362
}
6463
$valuesByNamespace = [$namespace => $query->pluck('value', 'key')->toArray()];
6564

6665
return $valuesByNamespace;
6766
}
67+
6868
public function missingSnippet($namespace, $key, $value)
6969
{
70-
Snippet::firstOrCreate(array(
70+
Snippet::firstOrCreate([
7171
'locale' => $this->app['config']['app.locale'],
7272
'namespace' => $namespace,
7373
'key' => $key,
74-
'value' => $value
75-
));
74+
'value' => $value,
75+
]);
76+
7677
return $value;
7778
}
7879
}

src/SnippetManagerServiceProvider.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,25 @@
22

33
namespace Moonshiner\SnippetManager;
44

5+
use Blade;
56
use Illuminate\Routing\Router;
67
use Illuminate\Support\ServiceProvider;
78

8-
use Blade;
9-
use App;
10-
119
class SnippetManagerServiceProvider extends ServiceProvider
1210
{
1311
protected $defer = false;
1412

1513
/**
1614
* Register any package services.
17-
*
18-
* @return void
1915
*/
2016
public function register()
2117
{
22-
$configPath = __DIR__ . '/../config/snippet-manager.php';
18+
$configPath = __DIR__.'/../config/snippet-manager.php';
2319

2420
$this->mergeConfigFrom($configPath, 'snippet-manager');
2521

2622
$this->publishes([$configPath => config_path('snippet-manager.php')], 'config');
2723

28-
2924
$this->app->singleton('snippet.manager', function ($app) {
3025
return new SnippetManager($app);
3126
});
@@ -65,10 +60,11 @@ public function boot(Router $router)
6560
$router->post('clearCache', 'Controller@clearCache');
6661
});
6762
}
63+
6864
public function provides()
6965
{
7066
return [
71-
'snippet.manager'
67+
'snippet.manager',
7268
];
7369
}
7470
}

0 commit comments

Comments
 (0)