@@ -1,29 +1,29 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Helpers; |
|
| 3 | + namespace App\Helpers; |
|
| 4 | 4 | |
| 5 | -use App\Singleton; |
|
| 6 | -use Illuminate\Support\Facades\Config; |
|
| 5 | + use App\Singleton; |
|
| 6 | + use Illuminate\Support\Facades\Config; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Class Validation. |
| 10 | 10 | */ |
| 11 | -final class Validation extends Singleton |
|
| 12 | -{ |
|
| 13 | - /** |
|
| 11 | + final class Validation extends Singleton |
|
| 12 | + { |
|
| 13 | + /** |
|
| 14 | 14 | * Filter an Username from the Invalid Names Base. |
| 15 | 15 | * |
| 16 | 16 | * @param string $username |
| 17 | 17 | * |
| 18 | 18 | * @return bool |
| 19 | 19 | */ |
| 20 | - public function filterUserName(string $username): bool |
|
| 21 | - { |
|
| 22 | - return $this->checkSize($username, 4, 15) && $this->checkWords($username) && |
|
| 23 | - preg_match('/^[a-zA-Z0-9_\-=?!@:.$]+$/', $username); |
|
| 24 | - } |
|
| 20 | + public function filterUserName(string $username): bool |
|
| 21 | + { |
|
| 22 | + return $this->checkSize($username, 4, 15) && $this->checkWords($username) && |
|
| 23 | + preg_match('/^[a-zA-Z0-9_\-=?!@:.$]+$/', $username); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | + /** |
|
| 27 | 27 | * Check String Size. |
| 28 | 28 | * |
| 29 | 29 | * @param string $needle |
@@ -32,22 +32,22 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public function checkSize(string $needle, int $min, int $max) |
|
| 36 | - { |
|
| 37 | - return strlen($needle) <= $max && strlen($needle) >= $min; |
|
| 38 | - } |
|
| 35 | + public function checkSize(string $needle, int $min, int $max) |
|
| 36 | + { |
|
| 37 | + return strlen($needle) <= $max && strlen($needle) >= $min; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | + /** |
|
| 41 | 41 | * Check for Illegal Words. |
| 42 | 42 | * |
| 43 | 43 | * @param string $needle |
| 44 | 44 | * |
| 45 | 45 | * @return bool |
| 46 | 46 | */ |
| 47 | - public function checkWords(string $needle): bool |
|
| 48 | - { |
|
| 49 | - return count(array_filter(Config::get('chocolatey.invalid'), function ($illegal) use ($needle) { |
|
| 50 | - return stripos($needle, $illegal) !== false; |
|
| 51 | - })) == 0; |
|
| 52 | - } |
|
| 47 | + public function checkWords(string $needle): bool |
|
| 48 | + { |
|
| 49 | + return count(array_filter(Config::get('chocolatey.invalid'), function ($illegal) use ($needle) { |
|
| 50 | + return stripos($needle, $illegal) !== false; |
|
| 51 | + })) == 0; |
|
| 52 | + } |
|
| 53 | 53 | } |