Passed
Push — master ( dc9824...6da3d4 )
by Hayri Can
01:18
created
src/Contracts/IpCheckerInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use Illuminate\Http\Request;
6 6
 
7
-interface IpCheckerInterface{
7
+interface IpCheckerInterface {
8 8
 
9 9
     public function getIpArray();
10 10
     /**
Please login to merge, or discard this patch.
database/migrations/2019_11_27_085806_create_ip_lists_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('ip_lists', function (Blueprint $table) {
16
+        Schema::create('ip_lists', function(Blueprint $table) {
17 17
             $table->bigIncrements('id');
18 18
             $table->string('group');
19 19
             $table->string('definition');
Please login to merge, or discard this patch.
routes/web.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 */
13 13
 
14 14
 
15
-Route::group(['prefix'=>config('ipchecker.settings.route_prefix')], function () {
15
+Route::group(['prefix'=>config('ipchecker.settings.route_prefix')], function() {
16 16
     Route::get('/iplists', 'HayriCan\IpChecker\Http\Controllers\IpCheckerController@index')->name('iplist.index');
17 17
     Route::post('/ip-add', 'HayriCan\IpChecker\Http\Controllers\IpCheckerController@add')->name('iplist.add');
18 18
     Route::delete('/ip-delete', 'HayriCan\IpChecker\Http\Controllers\IpCheckerController@delete')->name('iplist.delete');
Please login to merge, or discard this patch.
src/DBDriver.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 use HayriCan\IpChecker\Contracts\IpCheckerInterface;
6 6
 
7
-class DBDriver implements IpCheckerInterface{
7
+class DBDriver implements IpCheckerInterface {
8 8
 
9 9
     /**
10 10
      * Model for saving logs
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function getIpArray()
26 26
     {
27
-        foreach ($this->model->all() as $record){
28
-            array_push($this->ipList,$record->ip);
27
+        foreach ($this->model->all() as $record) {
28
+            array_push($this->ipList, $record->ip);
29 29
         }
30 30
         $ipList = $this->ipList ?? [];
31 31
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public function saveIp($array)
48 48
     {
49 49
         $result = IpList::create($array);
50
-        if (!$result){
50
+        if (!$result) {
51 51
             return false;
52 52
         }
53 53
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
     public function deleteIp($ipAddress)
62 62
     {
63 63
         $response = false;
64
-        $ipList = IpList::where('ip',$ipAddress)->first();
65
-        if ($ipList){
66
-            IpList::where('id',$ipList->id)->delete();
64
+        $ipList = IpList::where('ip', $ipAddress)->first();
65
+        if ($ipList) {
66
+            IpList::where('id', $ipList->id)->delete();
67 67
             $response = true;
68 68
         }
69 69
 
Please login to merge, or discard this patch.
src/FileDriver.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function saveIp($array)
77 77
     {
78
-        $array['created_at']=Carbon::now()->toDateTimeString();
78
+        $array['created_at'] = Carbon::now()->toDateTimeString();
79 79
         $filename = $this->getFilename();
80 80
 
81 81
         $contents = implode(";", $array);
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
                 if (!is_dir($file)) {
101 101
                     $lines = file($this->path.DIRECTORY_SEPARATOR.$file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
102 102
                     foreach ($lines as $line) {
103
-                        if (strpos($line, $ipAddress)){
103
+                        if (strpos($line, $ipAddress)) {
104 104
                             $contents = file_get_contents($this->path.DIRECTORY_SEPARATOR.$file);
105
-                            $contents = str_replace($line,'',$contents);
106
-                            file_put_contents($this->path.DIRECTORY_SEPARATOR.$file,$contents);
105
+                            $contents = str_replace($line, '', $contents);
106
+                            file_put_contents($this->path.DIRECTORY_SEPARATOR.$file, $contents);
107 107
                             return true;
108 108
                         }
109 109
                     }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @param array $data
123 123
      * @return IpList
124 124
      */
125
-    public function mapArrayToModel(array $data){
125
+    public function mapArrayToModel(array $data) {
126 126
         $model = new IpList();
127 127
         $model->group = $data[0];
128 128
         $model->definition = $data[1];
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     public function getFilename()
140 140
     {
141 141
         $filename = 'iplist.php';
142
-        if (config('ipchecker.filename')){
142
+        if (config('ipchecker.filename')) {
143 143
             $filename = config('ipchecker.filename');
144 144
         }
145 145
 
Please login to merge, or discard this patch.
src/IpCheckerServiceProvider.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public function register()
21 21
     {
22 22
         $this->mergeConfigFrom(
23
-            __DIR__ . '/../config/ipchecker.php', 'ipchecker'
23
+            __DIR__.'/../config/ipchecker.php', 'ipchecker'
24 24
         );
25 25
         $this->bindServices();
26 26
     }
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
         $this->loadConfig();
30 30
         $this->loadRoutes();
31 31
         $this->loadViews();
32
-        if (config('ipchecker.driver') === 'db'){
32
+        if (config('ipchecker.driver') === 'db') {
33 33
             $this->loadMigrations();
34 34
         }
35 35
     }
36 36
 
37
-    public function bindServices(){
37
+    public function bindServices() {
38 38
         $driver = config('ipchecker.driver');
39 39
         switch ($driver) {
40 40
             case 'file':
@@ -47,29 +47,29 @@  discard block
 block discarded – undo
47 47
                 throw new Exception("Unsupported Driver");
48 48
                 break;
49 49
         }
50
-        $this->app->singleton(IpCheckerInterface::class,$instance);
50
+        $this->app->singleton(IpCheckerInterface::class, $instance);
51 51
 
52
-        $this->app->singleton('ipchecker', function ($app) use ($instance){
52
+        $this->app->singleton('ipchecker', function($app) use ($instance){
53 53
             return new IpChecker($app->make($instance));
54 54
         });
55 55
     }
56 56
 
57
-    public function loadConfig(){
57
+    public function loadConfig() {
58 58
         $this->publishes([
59
-            __DIR__ . '/../config/ipchecker.php' => config_path('ipchecker.php')
59
+            __DIR__.'/../config/ipchecker.php' => config_path('ipchecker.php')
60 60
         ], 'ipchecker');
61 61
     }
62 62
 
63
-    public function loadRoutes(){
64
-        $this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
63
+    public function loadRoutes() {
64
+        $this->loadRoutesFrom(__DIR__.'/../routes/web.php');
65 65
     }
66 66
 
67
-    public function loadViews(){
68
-        $this->loadViewsFrom(__DIR__ . '/../resources/views', 'ipchecker');
67
+    public function loadViews() {
68
+        $this->loadViewsFrom(__DIR__.'/../resources/views', 'ipchecker');
69 69
     }
70 70
 
71
-    public function loadMigrations(){
72
-        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
71
+    public function loadMigrations() {
72
+        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
73 73
     }
74 74
 
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
src/Http/Middleware/IpChecker.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
     public function handle($request, Closure $next)
25 25
     {
26 26
         if (!in_array($request->ip(), $this->allowedIps->getIpArray())) {
27
-            if (in_array(config('ipchecker.api_middleware'),$request->route()->gatherMiddleware())){
27
+            if (in_array(config('ipchecker.api_middleware'), $request->route()->gatherMiddleware())) {
28 28
                 $return_array = config('ipchecker.api_response');
29 29
 
30
-                return response()->json($return_array,250,[],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
30
+                return response()->json($return_array, 250, [], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
31 31
             }
32 32
 
33 33
             $message = config('ipchecker.web_response');
34 34
 
35
-            return response()->view('ipchecker::error',compact('message'));
35
+            return response()->view('ipchecker::error', compact('message'));
36 36
         }
37 37
 
38 38
         return $next($request);
Please login to merge, or discard this patch.
src/Http/Controllers/IpCheckerController.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
     public function __construct()
19 19
     {
20 20
         if (config('ipchecker.settings.auth')) {
21
-            $this->middleware(['web','auth']);
21
+            $this->middleware(['web', 'auth']);
22 22
         }
23
-        else{
23
+        else {
24 24
             $this->middleware(['web']);
25 25
         }
26 26
     }
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $iplist = $ipchecker->getIpList();
37 37
 
38
-        if(count($iplist)>0){
38
+        if (count($iplist)>0) {
39 39
             $iplist = $iplist->sortByDesc('created_at');
40 40
         }
41 41
 
42
-        return view('ipchecker::index',compact('iplist'));
42
+        return view('ipchecker::index', compact('iplist'));
43 43
     }
44 44
 
45 45
     /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param IpCheckerInterface $ipchecker
48 48
      * @return \Illuminate\Http\RedirectResponse
49 49
      */
50
-    public function add(Request $request,IpCheckerInterface $ipchecker)
50
+    public function add(Request $request, IpCheckerInterface $ipchecker)
51 51
     {
52 52
         $request_data = $request->all();
53 53
         $request_validation = array(
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param IpCheckerInterface $ipchecker
75 75
      * @return \Illuminate\Http\RedirectResponse
76 76
      */
77
-    public function delete(Request $request,IpCheckerInterface $ipchecker)
77
+    public function delete(Request $request, IpCheckerInterface $ipchecker)
78 78
     {
79 79
         $ipchecker->deleteIp($request->input('ipAddress'));
80 80
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
19 19
     {
20 20
         if (config('ipchecker.settings.auth')) {
21 21
             $this->middleware(['web','auth']);
22
-        }
23
-        else{
22
+        } else{
24 23
             $this->middleware(['web']);
25 24
         }
26 25
     }
Please login to merge, or discard this patch.