Skip to content

Commit 031e6a2

Browse files
pravodevStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent e1737ed commit 031e6a2

File tree

7 files changed

+105
-102
lines changed

7 files changed

+105
-102
lines changed

config/laramoud.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
return [
4-
/**
4+
/*
55
* -------------------------------------------
66
* Module path
77
* - app
@@ -11,24 +11,22 @@
1111
*/
1212
'module_path' => base_path('modules'),
1313

14-
15-
1614
'spl_autoload' => true,
1715

1816
// work if spl_autoload true
1917
'namespaces' => [
2018
// "module_directory" => YourNameSpace
2119
],
2220

23-
/**
21+
/*
2422
*
2523
*/
2624
'observers' => [
2725
'autoboot' => true,
28-
'except' => []
26+
'except' => [],
2927
],
3028

3129
//laramoud.json
3230
//isinya
3331
//observer_autoboot
34-
];
32+
];

src/Contracts/Resource.php

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22

33
namespace Pravodev\Laramoud\Contracts;
4+
45
use Illuminate\Support\Facades\Route;
56

67
trait Resource
78
{
89
/**
9-
* Load View by namespace of module
10-
*
10+
* Load View by namespace of module.
11+
*
1112
* @return void
1213
*/
1314
public function loadViews($module_name)
@@ -18,19 +19,21 @@ public function loadViews($module_name)
1819
}
1920

2021
/**
21-
* Load Routes
22-
*
22+
* Load Routes.
23+
*
2324
* @return void
2425
*/
2526
public function loadRoutes($module_name)
2627
{
27-
foreach(['web', 'api'] as $route_file){
28+
foreach (['web', 'api'] as $route_file) {
2829
$path = $this->getModulePath($module_name.'/routes/'.$route_file.'.php');
29-
if(file_exists($path) == false) continue;
30+
if (file_exists($path) == false) {
31+
continue;
32+
}
3033
$namespace = $this->getNamespace($module_name, 'Http\Controllers');
3134
$route = Route::middleware($route_file)->namespace($namespace);
3235

33-
if($route_file == 'api'){
36+
if ($route_file == 'api') {
3437
$route->prefix($route_file);
3538
}
3639

@@ -39,7 +42,7 @@ public function loadRoutes($module_name)
3942
}
4043

4144
/**
42-
* Load Migrations
45+
* Load Migrations.
4346
*/
4447
public function loadMigrations($module_name)
4548
{
@@ -48,13 +51,14 @@ public function loadMigrations($module_name)
4851
}
4952

5053
/**
51-
* Get Module Namespace
52-
*
54+
* Get Module Namespace.
55+
*
5356
* @return string
5457
*/
55-
public function getNamespace($module_name, $name = "")
58+
public function getNamespace($module_name, $name = '')
5659
{
5760
$namespace = ucwords($module_name);
61+
5862
return $namespace.'\\'.$name;
5963
}
60-
}
64+
}

src/Laramoud.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Pravodev\Laramoud;
44

5-
class Laramoud
5+
class Laramoud
66
{
77
public function __construct()
88
{
@@ -11,11 +11,10 @@ public function __construct()
1111

1212
public function getModulePath()
1313
{
14-
1514
}
1615

1716
public function getConfig()
1817
{
1918
return $this->app->config('laramoud.');
2019
}
21-
}
20+
}

src/LaramoudServiceProvider.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pravodev\Laramoud;
44

5-
use Illuminate\Support\Facades\Route;
65
use Pravodev\Laramoud\Providers\ModuleServiceProvider;
76

87
class LaramoudServiceProvider extends ModuleServiceProvider
@@ -15,9 +14,9 @@ class LaramoudServiceProvider extends ModuleServiceProvider
1514
public function boot()
1615
{
1716
$this->publishes([
18-
__DIR__ . '/../config/laramoud.php' => \config_path('laramoud.php')
17+
__DIR__.'/../config/laramoud.php' => \config_path('laramoud.php'),
1918
]);
20-
19+
2120
$this->loadModules();
2221
}
2322
}

src/Providers/ModuleServiceProvider.php

+41-41
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,55 @@
33
namespace Pravodev\Laramoud\Providers;
44

55
use Illuminate\Support\ServiceProvider;
6-
use Pravodev\Laramoud\Utils\Cache;
76
use Pravodev\Laramoud\Contracts\Resource;
7+
use Pravodev\Laramoud\Utils\Cache;
88

99
abstract class ModuleServiceProvider extends ServiceProvider
1010
{
1111
use Resource;
12-
12+
1313
protected $cache;
14-
14+
1515
public function __construct($app)
1616
{
1717
parent::__construct($app);
1818

19-
$this->cache = new Cache;
19+
$this->cache = new Cache();
2020
}
21-
22-
public function boot(){}
2321

24-
public function register(){}
22+
public function boot()
23+
{
24+
}
25+
26+
public function register()
27+
{
28+
}
2529

26-
27-
/**
28-
*
29-
*/
3030
public function isAutoloadNamespaces()
3131
{
3232
return $this->getConfig('spl_autoload');
3333
}
3434

35-
3635
/**
37-
*
38-
*
3936
* @return void
4037
*/
4138
public function autoloadNamespaces()
4239
{
4340
$module_path = $this->getConfig('module_path');
44-
45-
spl_autoload_register(function($className)use($module_path){
46-
include_once $module_path . '/' . $className . '.php';
41+
42+
spl_autoload_register(function ($className) use ($module_path) {
43+
include_once $module_path.'/'.$className.'.php';
4744
});
4845
}
4946

5047
/**
51-
* Load View Routes Migration & OBservers of Module
52-
*
48+
* Load View Routes Migration & OBservers of Module.
49+
*
5350
* @return void
5451
*/
5552
public function loadModules()
5653
{
57-
foreach($this->getListOfModules() as $module){
54+
foreach ($this->getListOfModules() as $module) {
5855
$this->loadViews($module);
5956
$this->loadRoutes($module);
6057
$this->loadMigrations($module);
@@ -63,24 +60,26 @@ public function loadModules()
6360
}
6461

6562
/**
66-
* List Directory Modules
67-
*
63+
* List Directory Modules.
64+
*
6865
* @return array
6966
*/
7067
public function getListOfModules()
7168
{
72-
if($modules = $this->cache->get('laramoud', 'modules')){
69+
if ($modules = $this->cache->get('laramoud', 'modules')) {
7370
return $modules;
7471
}
7572

7673
$module_path = $this->getModulePath();
77-
78-
if(file_exists($module_path) == false) return [];
74+
75+
if (file_exists($module_path) == false) {
76+
return [];
77+
}
7978

8079
$modules = array_values(
8180
array_diff(
8281
scandir($this->getModulePath(), 1),
83-
array('..', '.')
82+
['..', '.']
8483
)
8584
);
8685

@@ -89,43 +88,44 @@ public function getListOfModules()
8988
return $modules;
9089
}
9190

92-
public function getModulePath($name = "")
91+
public function getModulePath($name = '')
9392
{
94-
if($config = $this->getConfig('module_path', 'composer')){
95-
return base_path($config . $name);
93+
if ($config = $this->getConfig('module_path', 'composer')) {
94+
return base_path($config.$name);
9695
}
97-
98-
return base_path("modules/" . $name);
96+
97+
return base_path('modules/'.$name);
9998
}
100-
99+
101100
/**
102-
* Get Laramoud Config
103-
*
101+
* Get Laramoud Config.
102+
*
104103
* @return any
105104
*/
106105
public function getConfig($key = null, $source = null)
107106
{
108-
if($source == 'composer'){
107+
if ($source == 'composer') {
109108
$config = $this->getComposer();
109+
110110
return $config['extra']['laramoud'][$key] ?? null;
111111
}
112-
113-
if(empty($key)){
112+
113+
if (empty($key)) {
114114
return config('laramoud');
115115
}
116116

117-
return config('laramoud.' . $key);
117+
return config('laramoud.'.$key);
118118
}
119119

120120
public function getComposer()
121121
{
122-
123-
if($composer = $this->cache->get('composer')){
122+
if ($composer = $this->cache->get('composer')) {
124123
return $composer;
125124
}
126125
// dd(as);
127126
$composer = json_decode(file_get_contents(base_path('composer.json')), true);
128127
$this->cache->set('composer', $composer);
128+
129129
return $composer;
130130
}
131-
}
131+
}

0 commit comments

Comments
 (0)