| @@ -15,7 +15,7 @@ | ||
| 15 | 15 | |
| 16 | 16 | public function setUp(): void | 
| 17 | 17 |      { | 
| 18 | - parent::setUp(); | |
| 18 | + parent::setUp(); | |
| 19 | 19 | } | 
| 20 | 20 | |
| 21 | 21 | protected function defineDatabaseMigrations() | 
| @@ -27,7 +27,7 @@ | ||
| 27 | 27 | protected function defineRoutes($router) | 
| 28 | 28 |      { | 
| 29 | 29 | // Define routes. | 
| 30 | -        $router->get('login', function () { | |
| 30 | +        $router->get('login', function() { | |
| 31 | 31 | return 'login'; | 
| 32 | 32 |          })->name('login'); | 
| 33 | 33 | |
| @@ -21,7 +21,7 @@ | ||
| 21 | 21 | |
| 22 | 22 | $user = TestUser::create([ | 
| 23 | 23 | 'name' => str::random(), | 
| 24 | - 'email' => Str::random(40) . '@example.com', | |
| 24 | + 'email' => Str::random(40).'@example.com', | |
| 25 | 25 |              'password' => Hash::make('password'), | 
| 26 | 26 |              'pin' => Hash::make('0000'), | 
| 27 | 27 | ]); | 
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 |  { | 
| 16 | 16 | use WithFaker; | 
| 17 | 17 | |
| 18 | - /** | |
| 18 | + /** | |
| 19 | 19 | * A basic feature test example. | 
| 20 | 20 | * | 
| 21 | 21 | * @return void | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | |
| 29 | 29 | $user = TestUser::create([ | 
| 30 | 30 | 'name' => str::random(), | 
| 31 | - 'email' => Str::random(40) . '@example.com', | |
| 31 | + 'email' => Str::random(40).'@example.com', | |
| 32 | 32 |              'password' => Hash::make('password'), | 
| 33 | 33 |              'pin' => Hash::make(config('requirepin.default', '0000')) | 
| 34 | 34 | ]); // Would still have the default pin | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 |      { | 
| 58 | 58 | $user = TestUser::create([ | 
| 59 | 59 | 'name' => str::random(), | 
| 60 | - 'email' => Str::random(40) . '@example.com', | |
| 60 | + 'email' => Str::random(40).'@example.com', | |
| 61 | 61 |              'password' => Hash::make('password'), | 
| 62 | 62 |              'pin' => Hash::make(config('requirepin.default', '0000')), | 
| 63 | 63 | ]); | 
| @@ -76,14 +76,14 @@ discard block | ||
| 76 | 76 | $responseArray = json_decode($response->getContent(), true); | 
| 77 | 77 | |
| 78 | 78 | $this->assertEquals(200, $responseArray['status_code']); | 
| 79 | - $this->assertEquals( 'success', $responseArray['status']); | |
| 79 | +        $this->assertEquals('success', $responseArray['status']); | |
| 80 | 80 | } | 
| 81 | 81 | |
| 82 | 82 | public function testRequirePinMiddleWareForCreateBookWeb() | 
| 83 | 83 |      { | 
| 84 | 84 | $user = TestUser::create([ | 
| 85 | 85 | 'name' => str::random(), | 
| 86 | - 'email' => Str::random(40) . '@example.com', | |
| 86 | + 'email' => Str::random(40).'@example.com', | |
| 87 | 87 |              'password' => Hash::make('password'), | 
| 88 | 88 |              'pin' => Hash::make('1234'), | 
| 89 | 89 | 'default_pin' => 0 | 
| @@ -94,11 +94,11 @@ discard block | ||
| 94 | 94 |          $this->assertTrue(Hash::check('1234', $user->pin)); | 
| 95 | 95 | |
| 96 | 96 | $postData = [ | 
| 97 | - 'name' => $this->faker->sentence(rand(1,5)), | |
| 97 | + 'name' => $this->faker->sentence(rand(1, 5)), | |
| 98 | 98 | 'isbn' => $this->faker->unique()->isbn13(), | 
| 99 | 99 |              'authors' => implode(",", [$this->faker->name(), $this->faker->name()]), | 
| 100 | 100 | 'publisher' => $this->faker->name(), | 
| 101 | - 'number_of_pages' => rand(45,1500), | |
| 101 | + 'number_of_pages' => rand(45, 1500), | |
| 102 | 102 | 'country' => $this->faker->countryISOAlpha3(), | 
| 103 | 103 |              'release_date' => date('Y-m-d') | 
| 104 | 104 | ]; | 
| @@ -111,7 +111,7 @@ discard block | ||
| 111 | 111 |      { | 
| 112 | 112 | $user = TestUser::create([ | 
| 113 | 113 | 'name' => str::random(), | 
| 114 | - 'email' => Str::random(40) . '@example.com', | |
| 114 | + 'email' => Str::random(40).'@example.com', | |
| 115 | 115 |              'password' => Hash::make('password'), | 
| 116 | 116 |              'pin' => Hash::make('1234'), | 
| 117 | 117 | 'default_pin' => 0 | 
| @@ -125,11 +125,11 @@ discard block | ||
| 125 | 125 | |
| 126 | 126 |          if (!isset($book->id)) { | 
| 127 | 127 | $book = Book::create([ | 
| 128 | - 'name' => $this->faker->sentence(rand(1,5)), | |
| 128 | + 'name' => $this->faker->sentence(rand(1, 5)), | |
| 129 | 129 | 'isbn' => $this->faker->unique()->isbn13(), | 
| 130 | 130 |                  'authors' => implode(",", [$this->faker->name(), $this->faker->name()]), | 
| 131 | 131 | 'publisher' => $this->faker->name(), | 
| 132 | - 'number_of_pages' => rand(45,1500), | |
| 132 | + 'number_of_pages' => rand(45, 1500), | |
| 133 | 133 | 'country' => $this->faker->countryISOAlpha3(), | 
| 134 | 134 |                  'release_date' => date('Y-m-d') | 
| 135 | 135 | ]); | 
| @@ -145,7 +145,7 @@ discard block | ||
| 145 | 145 |      { | 
| 146 | 146 | $user = TestUser::create([ | 
| 147 | 147 | 'name' => str::random(), | 
| 148 | - 'email' => Str::random(40) . '@example.com', | |
| 148 | + 'email' => Str::random(40).'@example.com', | |
| 149 | 149 |              'password' => Hash::make('password'), | 
| 150 | 150 |              'pin' => Hash::make('1234'), | 
| 151 | 151 | 'default_pin' => 0 | 
| @@ -159,11 +159,11 @@ discard block | ||
| 159 | 159 | |
| 160 | 160 |          if (!isset($book->id)) { | 
| 161 | 161 | $book = Book::create([ | 
| 162 | - 'name' => $this->faker->sentence(rand(1,5)), | |
| 162 | + 'name' => $this->faker->sentence(rand(1, 5)), | |
| 163 | 163 | 'isbn' => $this->faker->unique()->isbn13(), | 
| 164 | 164 |                  'authors' => implode(",", [$this->faker->name(), $this->faker->name()]), | 
| 165 | 165 | 'publisher' => $this->faker->name(), | 
| 166 | - 'number_of_pages' => rand(45,1500), | |
| 166 | + 'number_of_pages' => rand(45, 1500), | |
| 167 | 167 | 'country' => $this->faker->countryISOAlpha3(), | 
| 168 | 168 |                  'release_date' => date('Y-m-d') | 
| 169 | 169 | ]); | 
| @@ -194,7 +194,7 @@ discard block | ||
| 194 | 194 |      { | 
| 195 | 195 | $user = TestUser::create([ | 
| 196 | 196 | 'name' => str::random(), | 
| 197 | - 'email' => Str::random(40) . '@example.com', | |
| 197 | + 'email' => Str::random(40).'@example.com', | |
| 198 | 198 |              'password' => Hash::make('password'), | 
| 199 | 199 |              'pin' => Hash::make('1234'), | 
| 200 | 200 | 'default_pin' => 0 | 
| @@ -205,11 +205,11 @@ discard block | ||
| 205 | 205 |          $this->assertTrue(Hash::check('1234', $user->pin)); | 
| 206 | 206 | |
| 207 | 207 | $postData = [ | 
| 208 | - 'name' => $this->faker->sentence(rand(1,5)), | |
| 208 | + 'name' => $this->faker->sentence(rand(1, 5)), | |
| 209 | 209 | 'isbn' => $this->faker->unique()->isbn13(), | 
| 210 | 210 |              'authors' => implode(",", [$this->faker->name(), $this->faker->name()]), | 
| 211 | 211 | 'publisher' => $this->faker->name(), | 
| 212 | - 'number_of_pages' => rand(45,1500), | |
| 212 | + 'number_of_pages' => rand(45, 1500), | |
| 213 | 213 | 'country' => $this->faker->countryISOAlpha3(), | 
| 214 | 214 |              'release_date' => date('Y-m-d') | 
| 215 | 215 | ]; | 
| @@ -17,32 +17,32 @@ | ||
| 17 | 17 | $this->delayMinutes = $maxAttempts; | 
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | - public function hasTooManyAttempts (Request $request) | |
| 20 | + public function hasTooManyAttempts(Request $request) | |
| 21 | 21 |      { | 
| 22 | 22 | return $this->hasTooManyLoginAttempts($request); | 
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | - public function incrementAttempts (Request $request) | |
| 25 | + public function incrementAttempts(Request $request) | |
| 26 | 26 |      { | 
| 27 | 27 | return $this->incrementLoginAttempts($request); | 
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | - public function clearAttempts (Request $request) | |
| 30 | + public function clearAttempts(Request $request) | |
| 31 | 31 |      { | 
| 32 | 32 | return $this->clearLoginAttempts($request); | 
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | - public function _fireLockoutEvent (Request $request) | |
| 35 | + public function _fireLockoutEvent(Request $request) | |
| 36 | 36 |      { | 
| 37 | 37 | return $this->fireLockoutEvent($request); | 
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | - public function _limiter () | |
| 40 | + public function _limiter() | |
| 41 | 41 |      { | 
| 42 | 42 | return $this->limiter(); | 
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | - public function _throttleKey (Request $request) | |
| 45 | + public function _throttleKey(Request $request) | |
| 46 | 46 |      { | 
| 47 | 47 | return $this->throttleKey($request); | 
| 48 | 48 | } | 
| @@ -14,7 +14,7 @@ discard block | ||
| 14 | 14 | */ | 
| 15 | 15 | public function up() | 
| 16 | 16 |      { | 
| 17 | -        Schema::table('users', function (Blueprint $table) { | |
| 17 | +        Schema::table('users', function(Blueprint $table) { | |
| 18 | 18 |              $table->string('pin')->after('password')->default(Hash::make(config('requirepin.default', '0000'))); | 
| 19 | 19 |              $table->tinyInteger('default_pin')->after('pin')->default(1); | 
| 20 | 20 | }); | 
| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 | */ | 
| 28 | 28 | public function down() | 
| 29 | 29 |      { | 
| 30 | -        Schema::table('users', function (Blueprint $table) { | |
| 30 | +        Schema::table('users', function(Blueprint $table) { | |
| 31 | 31 | $table->dropColumn(['pin', 'default_pin']); | 
| 32 | 32 | }); | 
| 33 | 33 | } | 
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 | public function up() | 
| 15 | 15 |      { | 
| 16 | -        Schema::create('old_pins', function (Blueprint $table) { | |
| 16 | +        Schema::create('old_pins', function(Blueprint $table) { | |
| 17 | 17 | $table->id(); | 
| 18 | 18 |              $table->foreignId('user_id')->constrained('users'); | 
| 19 | 19 |              $table->string('pin'); | 
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 | public function up() | 
| 15 | 15 |      { | 
| 16 | -        Schema::create('require_pins', function (Blueprint $table) { | |
| 16 | +        Schema::create('require_pins', function(Blueprint $table) { | |
| 17 | 17 | $table->id(); | 
| 18 | 18 |              $table->foreignId('user_id')->constrained('users'); | 
| 19 | 19 |              $table->string('uuid')->unique(); | 
| @@ -4,7 +4,7 @@ | ||
| 4 | 4 | use Illuminate\Support\Facades\Route; | 
| 5 | 5 | use Ikechukwukalu\Requirepin\Controllers\PinController; | 
| 6 | 6 | |
| 7 | -Route::middleware('auth:sanctum')->group(function () { | |
| 7 | +Route::middleware('auth:sanctum')->group(function() { | |
| 8 | 8 |      Route::post('change/pin', [PinController::class, 'changePin']) | 
| 9 | 9 |          ->name('changePin'); | 
| 10 | 10 | |
| @@ -68,13 +68,13 @@ | ||
| 68 | 68 | 'REMOTE_ADDR' | 
| 69 | 69 | ]; | 
| 70 | 70 | |
| 71 | -        foreach ($server_keys as $key){ | |
| 71 | +        foreach ($server_keys as $key) { | |
| 72 | 72 |              if (array_key_exists($key, $_SERVER) === true) { | 
| 73 | 73 |                  foreach (explode(',', $_SERVER[$key]) as $ip) { | 
| 74 | 74 | $ip = trim($ip); // just to be safe | 
| 75 | 75 | |
| 76 | 76 | if (filter_var($ip, FILTER_VALIDATE_IP, | 
| 77 | - FILTER_FLAG_NO_PRIV_RANGE | | |
| 77 | + FILTER_FLAG_NO_PRIV_RANGE| | |
| 78 | 78 | FILTER_FLAG_NO_RES_RANGE) !== false | 
| 79 | 79 |                      ) { | 
| 80 | 80 | return $ip; |