@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | 'keys' => [ |
| 49 | 49 | |
| 50 | - /* |
|
| 50 | + /* |
|
| 51 | 51 | |-------------------------------------------------------------------------- |
| 52 | 52 | | Public Key |
| 53 | 53 | |-------------------------------------------------------------------------- |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | | |
| 59 | 59 | */ |
| 60 | 60 | |
| 61 | - 'public' => env('JWT_PUBLIC_KEY'), |
|
| 61 | + 'public' => env('JWT_PUBLIC_KEY'), |
|
| 62 | 62 | |
| 63 | - /* |
|
| 63 | + /* |
|
| 64 | 64 | |-------------------------------------------------------------------------- |
| 65 | 65 | | Private Key |
| 66 | 66 | |-------------------------------------------------------------------------- |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | | |
| 72 | 72 | */ |
| 73 | 73 | |
| 74 | - 'private' => env('JWT_PRIVATE_KEY'), |
|
| 74 | + 'private' => env('JWT_PRIVATE_KEY'), |
|
| 75 | 75 | |
| 76 | - /* |
|
| 76 | + /* |
|
| 77 | 77 | |-------------------------------------------------------------------------- |
| 78 | 78 | | Passphrase |
| 79 | 79 | |-------------------------------------------------------------------------- |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | | |
| 83 | 83 | */ |
| 84 | 84 | |
| 85 | - 'passphrase' => env('JWT_PASSPHRASE'), |
|
| 85 | + 'passphrase' => env('JWT_PASSPHRASE'), |
|
| 86 | 86 | |
| 87 | 87 | ], |
| 88 | 88 | |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | |
| 150 | 150 | 'required_claims' => [ |
| 151 | - 'iss', |
|
| 152 | - 'iat', |
|
| 153 | - 'exp', |
|
| 154 | - 'nbf', |
|
| 155 | - 'sub', |
|
| 156 | - 'jti', |
|
| 151 | + 'iss', |
|
| 152 | + 'iat', |
|
| 153 | + 'exp', |
|
| 154 | + 'nbf', |
|
| 155 | + 'sub', |
|
| 156 | + 'jti', |
|
| 157 | 157 | ], |
| 158 | 158 | |
| 159 | 159 | /* |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | |
| 172 | 172 | 'persistent_claims' => [ |
| 173 | - // 'foo', |
|
| 174 | - // 'bar', |
|
| 173 | + // 'foo', |
|
| 174 | + // 'bar', |
|
| 175 | 175 | ], |
| 176 | 176 | |
| 177 | 177 | /* |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | 'providers' => [ |
| 214 | 214 | |
| 215 | - /* |
|
| 215 | + /* |
|
| 216 | 216 | |-------------------------------------------------------------------------- |
| 217 | 217 | | JWT Provider |
| 218 | 218 | |-------------------------------------------------------------------------- |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | | |
| 222 | 222 | */ |
| 223 | 223 | |
| 224 | - 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class, |
|
| 224 | + 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class, |
|
| 225 | 225 | |
| 226 | - /* |
|
| 226 | + /* |
|
| 227 | 227 | |-------------------------------------------------------------------------- |
| 228 | 228 | | Authentication Provider |
| 229 | 229 | |-------------------------------------------------------------------------- |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | | |
| 233 | 233 | */ |
| 234 | 234 | |
| 235 | - 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class, |
|
| 235 | + 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class, |
|
| 236 | 236 | |
| 237 | - /* |
|
| 237 | + /* |
|
| 238 | 238 | |-------------------------------------------------------------------------- |
| 239 | 239 | | Storage Provider |
| 240 | 240 | |-------------------------------------------------------------------------- |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | | |
| 244 | 244 | */ |
| 245 | 245 | |
| 246 | - 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class, |
|
| 246 | + 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class, |
|
| 247 | 247 | |
| 248 | 248 | ], |
| 249 | 249 | |
@@ -29,16 +29,16 @@ |
||
| 29 | 29 | | |
| 30 | 30 | */ |
| 31 | 31 | 'connections' => [ |
| 32 | - 'mysql' => [ |
|
| 33 | - 'driver' => 'mysql', |
|
| 34 | - 'host' => env('DB_HOST', 'localhost'), |
|
| 35 | - 'database' => env('DB_DATABASE'), |
|
| 36 | - 'username' => env('DB_USERNAME'), |
|
| 37 | - 'password' => env('DB_PASSWORD'), |
|
| 38 | - 'charset' => 'utf8', |
|
| 39 | - 'collation' => 'utf8_unicode_ci', |
|
| 40 | - 'prefix' => '', |
|
| 41 | - 'strict' => false, |
|
| 42 | - ] |
|
| 32 | + 'mysql' => [ |
|
| 33 | + 'driver' => 'mysql', |
|
| 34 | + 'host' => env('DB_HOST', 'localhost'), |
|
| 35 | + 'database' => env('DB_DATABASE'), |
|
| 36 | + 'username' => env('DB_USERNAME'), |
|
| 37 | + 'password' => env('DB_PASSWORD'), |
|
| 38 | + 'charset' => 'utf8', |
|
| 39 | + 'collation' => 'utf8_unicode_ci', |
|
| 40 | + 'prefix' => '', |
|
| 41 | + 'strict' => false, |
|
| 42 | + ] |
|
| 43 | 43 | ], |
| 44 | 44 | ]; |
| 45 | 45 | \ No newline at end of file |
@@ -3,22 +3,22 @@ |
||
| 3 | 3 | |
| 4 | 4 | return [ |
| 5 | 5 | 'defaults' => [ |
| 6 | - 'guard' => env('AUTH_GUARD', 'api'), |
|
| 7 | - 'passwords' => 'users', |
|
| 6 | + 'guard' => env('AUTH_GUARD', 'api'), |
|
| 7 | + 'passwords' => 'users', |
|
| 8 | 8 | ], |
| 9 | 9 | 'guards' => [ |
| 10 | - 'api' => [ |
|
| 11 | - 'driver' => 'jwt-auth', |
|
| 12 | - 'provider' => 'users' |
|
| 13 | - ], |
|
| 10 | + 'api' => [ |
|
| 11 | + 'driver' => 'jwt-auth', |
|
| 12 | + 'provider' => 'users' |
|
| 13 | + ], |
|
| 14 | 14 | |
| 15 | - // ... |
|
| 15 | + // ... |
|
| 16 | 16 | ], |
| 17 | 17 | |
| 18 | 18 | 'providers' => [ |
| 19 | - 'users' => [ |
|
| 20 | - 'driver' => 'doctrine', |
|
| 21 | - 'model' => \Tfboe\FmLib\Entity\User::class |
|
| 22 | - ], |
|
| 19 | + 'users' => [ |
|
| 20 | + 'driver' => 'doctrine', |
|
| 21 | + 'model' => \Tfboe\FmLib\Entity\User::class |
|
| 22 | + ], |
|
| 23 | 23 | ], |
| 24 | 24 | ]; |
| 25 | 25 | \ No newline at end of file |
@@ -22,23 +22,23 @@ discard block |
||
| 22 | 22 | | |
| 23 | 23 | */ |
| 24 | 24 | 'managers' => [ |
| 25 | - 'default' => [ |
|
| 26 | - 'dev' => env('APP_DEBUG'), |
|
| 27 | - 'meta' => env('DOCTRINE_METADATA', 'annotations'), |
|
| 28 | - 'connection' => env('DB_CONNECTION', 'mysql'), |
|
| 29 | - 'namespaces' => [ |
|
| 30 | - 'Tfboe\FmLib\Entity' |
|
| 31 | - ], |
|
| 32 | - 'paths' => [ |
|
| 33 | - base_path('vendor/tfboe/fm-lib/src/Entity'), |
|
| 34 | - ], |
|
| 35 | - 'repository' => Doctrine\ORM\EntityRepository::class, |
|
| 36 | - 'proxies' => [ |
|
| 37 | - 'namespace' => false, |
|
| 38 | - 'path' => storage_path('proxies'), |
|
| 39 | - 'auto_generate' => env('DOCTRINE_PROXY_AUTOGENERATE', false) |
|
| 40 | - ], |
|
| 41 | - /* |
|
| 25 | + 'default' => [ |
|
| 26 | + 'dev' => env('APP_DEBUG'), |
|
| 27 | + 'meta' => env('DOCTRINE_METADATA', 'annotations'), |
|
| 28 | + 'connection' => env('DB_CONNECTION', 'mysql'), |
|
| 29 | + 'namespaces' => [ |
|
| 30 | + 'Tfboe\FmLib\Entity' |
|
| 31 | + ], |
|
| 32 | + 'paths' => [ |
|
| 33 | + base_path('vendor/tfboe/fm-lib/src/Entity'), |
|
| 34 | + ], |
|
| 35 | + 'repository' => Doctrine\ORM\EntityRepository::class, |
|
| 36 | + 'proxies' => [ |
|
| 37 | + 'namespace' => false, |
|
| 38 | + 'path' => storage_path('proxies'), |
|
| 39 | + 'auto_generate' => env('DOCTRINE_PROXY_AUTOGENERATE', false) |
|
| 40 | + ], |
|
| 41 | + /* |
|
| 42 | 42 | |-------------------------------------------------------------------------- |
| 43 | 43 | | Doctrine events |
| 44 | 44 | |-------------------------------------------------------------------------- |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | | e.g. Doctrine\ORM\Events::onFlush |
| 48 | 48 | | |
| 49 | 49 | */ |
| 50 | - 'events' => [ |
|
| 51 | - 'listeners' => [], |
|
| 52 | - 'subscribers' => [] |
|
| 53 | - ], |
|
| 54 | - 'filters' => [], |
|
| 55 | - /* |
|
| 50 | + 'events' => [ |
|
| 51 | + 'listeners' => [], |
|
| 52 | + 'subscribers' => [] |
|
| 53 | + ], |
|
| 54 | + 'filters' => [], |
|
| 55 | + /* |
|
| 56 | 56 | |-------------------------------------------------------------------------- |
| 57 | 57 | | Doctrine mapping types |
| 58 | 58 | |-------------------------------------------------------------------------- |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | | http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool |
| 76 | 76 | |-------------------------------------------------------------------------- |
| 77 | 77 | */ |
| 78 | - 'mapping_types' => [ |
|
| 79 | - //'enum' => 'string' |
|
| 80 | - ] |
|
| 81 | - ] |
|
| 78 | + 'mapping_types' => [ |
|
| 79 | + //'enum' => 'string' |
|
| 80 | + ] |
|
| 81 | + ] |
|
| 82 | 82 | ], |
| 83 | 83 | /* |
| 84 | 84 | |-------------------------------------------------------------------------- |
@@ -92,16 +92,16 @@ discard block |
||
| 92 | 92 | | |
| 93 | 93 | */ |
| 94 | 94 | 'extensions' => [ |
| 95 | - //LaravelDoctrine\ORM\Extensions\TablePrefix\TablePrefixExtension::class, |
|
| 96 | - LaravelDoctrine\Extensions\Timestamps\TimestampableExtension::class, |
|
| 97 | - //LaravelDoctrine\Extensions\SoftDeletes\SoftDeleteableExtension::class, |
|
| 98 | - //LaravelDoctrine\Extensions\Sluggable\SluggableExtension::class, |
|
| 99 | - //LaravelDoctrine\Extensions\Sortable\SortableExtension::class, |
|
| 100 | - //LaravelDoctrine\Extensions\Tree\TreeExtension::class, |
|
| 101 | - //LaravelDoctrine\Extensions\Loggable\LoggableExtension::class, |
|
| 102 | - //LaravelDoctrine\Extensions\Blameable\BlameableExtension::class, |
|
| 103 | - //LaravelDoctrine\Extensions\IpTraceable\IpTraceableExtension::class, |
|
| 104 | - //LaravelDoctrine\Extensions\Translatable\TranslatableExtension::class |
|
| 95 | + //LaravelDoctrine\ORM\Extensions\TablePrefix\TablePrefixExtension::class, |
|
| 96 | + LaravelDoctrine\Extensions\Timestamps\TimestampableExtension::class, |
|
| 97 | + //LaravelDoctrine\Extensions\SoftDeletes\SoftDeleteableExtension::class, |
|
| 98 | + //LaravelDoctrine\Extensions\Sluggable\SluggableExtension::class, |
|
| 99 | + //LaravelDoctrine\Extensions\Sortable\SortableExtension::class, |
|
| 100 | + //LaravelDoctrine\Extensions\Tree\TreeExtension::class, |
|
| 101 | + //LaravelDoctrine\Extensions\Loggable\LoggableExtension::class, |
|
| 102 | + //LaravelDoctrine\Extensions\Blameable\BlameableExtension::class, |
|
| 103 | + //LaravelDoctrine\Extensions\IpTraceable\IpTraceableExtension::class, |
|
| 104 | + //LaravelDoctrine\Extensions\Translatable\TranslatableExtension::class |
|
| 105 | 105 | ], |
| 106 | 106 | /* |
| 107 | 107 | |-------------------------------------------------------------------------- |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |-------------------------------------------------------------------------- |
| 113 | 113 | */ |
| 114 | 114 | 'custom_types' => [ |
| 115 | - 'json' => LaravelDoctrine\ORM\Types\Json::class |
|
| 115 | + 'json' => LaravelDoctrine\ORM\Types\Json::class |
|
| 116 | 116 | ], |
| 117 | 117 | /* |
| 118 | 118 | |-------------------------------------------------------------------------- |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | | |
| 158 | 158 | */ |
| 159 | 159 | 'cache' => [ |
| 160 | - 'default' => env('DOCTRINE_CACHE', 'array'), |
|
| 161 | - 'namespace' => null, |
|
| 162 | - 'second_level' => false, |
|
| 160 | + 'default' => env('DOCTRINE_CACHE', 'array'), |
|
| 161 | + 'namespace' => null, |
|
| 162 | + 'second_level' => false, |
|
| 163 | 163 | ], |
| 164 | 164 | /* |
| 165 | 165 | |-------------------------------------------------------------------------- |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | | |
| 173 | 173 | */ |
| 174 | 174 | 'gedmo' => [ |
| 175 | - 'all_mappings' => false |
|
| 175 | + 'all_mappings' => false |
|
| 176 | 176 | ], |
| 177 | 177 | /* |
| 178 | 178 | |-------------------------------------------------------------------------- |
@@ -193,6 +193,6 @@ discard block |
||
| 193 | 193 | | |
| 194 | 194 | */ |
| 195 | 195 | 'notifications' => [ |
| 196 | - 'channel' => 'database' |
|
| 196 | + 'channel' => 'database' |
|
| 197 | 197 | ] |
| 198 | 198 | ]; |
@@ -13,28 +13,28 @@ |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | 'stores' => [ |
| 16 | - 'array' => [ |
|
| 17 | - 'driver' => 'array' |
|
| 18 | - ], |
|
| 19 | - 'apc' => [ |
|
| 20 | - 'driver' => 'apc', |
|
| 21 | - ], |
|
| 22 | - 'file' => [ |
|
| 23 | - 'driver' => 'file', |
|
| 24 | - 'path' => storage_path('framework/cache'), |
|
| 25 | - ], |
|
| 26 | - 'memcached' => [ |
|
| 27 | - 'driver' => 'memcached', |
|
| 28 | - 'servers' => [ |
|
| 29 | - [ |
|
| 30 | - 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100, |
|
| 31 | - ], |
|
| 32 | - ], |
|
| 33 | - ], |
|
| 34 | - 'redis' => [ |
|
| 35 | - 'driver' => 'redis', |
|
| 36 | - 'connection' => 'default', |
|
| 37 | - ], |
|
| 16 | + 'array' => [ |
|
| 17 | + 'driver' => 'array' |
|
| 18 | + ], |
|
| 19 | + 'apc' => [ |
|
| 20 | + 'driver' => 'apc', |
|
| 21 | + ], |
|
| 22 | + 'file' => [ |
|
| 23 | + 'driver' => 'file', |
|
| 24 | + 'path' => storage_path('framework/cache'), |
|
| 25 | + ], |
|
| 26 | + 'memcached' => [ |
|
| 27 | + 'driver' => 'memcached', |
|
| 28 | + 'servers' => [ |
|
| 29 | + [ |
|
| 30 | + 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100, |
|
| 31 | + ], |
|
| 32 | + ], |
|
| 33 | + ], |
|
| 34 | + 'redis' => [ |
|
| 35 | + 'driver' => 'redis', |
|
| 36 | + 'connection' => 'default', |
|
| 37 | + ], |
|
| 38 | 38 | ], |
| 39 | 39 | |
| 40 | 40 | 'default' => env('CACHE_DRIVER'), |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * too short |
| 21 | 21 | */ |
| 22 | 22 | $router->post('register', [ |
| 23 | - 'as' => 'register', 'uses' => 'UserController@register' |
|
| 23 | + 'as' => 'register', 'uses' => 'UserController@register' |
|
| 24 | 24 | ]); |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | * too short |
| 40 | 40 | */ |
| 41 | 41 | $router->post('login', [ |
| 42 | - 'as' => 'login', 'uses' => 'UserController@login' |
|
| 42 | + 'as' => 'login', 'uses' => 'UserController@login' |
|
| 43 | 43 | ]); |
| 44 | 44 | |
| 45 | 45 | $router->group(['middleware' => 'auth:api'], function () use ($router) { |
| 46 | - /** |
|
| 47 | - * @api {get} /userId Get User ID |
|
| 48 | - * @apiUse AuthenticatedRequest |
|
| 49 | - * @apiVersion 0.1.0 |
|
| 50 | - * @apiDescription Gets the user id of the currently logged in user |
|
| 51 | - * @apiName GetUserId |
|
| 52 | - * @apiGroup User |
|
| 53 | - * |
|
| 54 | - * @apiSuccess {string} id the id of the user |
|
| 55 | - */ |
|
| 56 | - $router->get('userId', [ |
|
| 57 | - 'as' => 'userId', 'uses' => 'UserController@userId' |
|
| 58 | - ]); |
|
| 46 | + /** |
|
| 47 | + * @api {get} /userId Get User ID |
|
| 48 | + * @apiUse AuthenticatedRequest |
|
| 49 | + * @apiVersion 0.1.0 |
|
| 50 | + * @apiDescription Gets the user id of the currently logged in user |
|
| 51 | + * @apiName GetUserId |
|
| 52 | + * @apiGroup User |
|
| 53 | + * |
|
| 54 | + * @apiSuccess {string} id the id of the user |
|
| 55 | + */ |
|
| 56 | + $router->get('userId', [ |
|
| 57 | + 'as' => 'userId', 'uses' => 'UserController@userId' |
|
| 58 | + ]); |
|
| 59 | 59 | }); |
| 60 | 60 | }); |
| 61 | 61 | \ No newline at end of file |
@@ -38,20 +38,20 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | public static function log(string $message, string $logger = Logs::GENERAL, int $type = Logger::INFO) |
| 40 | 40 | { |
| 41 | - if (self::$testing && $logger !== Logs::TESTING) { |
|
| 42 | - //do nothing |
|
| 43 | - return; |
|
| 44 | - } |
|
| 45 | - Logs::ensureValidValue($logger); |
|
| 46 | - if (!array_key_exists($logger, self::$loggers)) { |
|
| 47 | - self::$loggers[$logger] = new Logger($logger); |
|
| 48 | - // InvalidArgumentException => stream is a string |
|
| 49 | - // Exception => path is static and it is ensured that it is valid |
|
| 50 | - /** @noinspection PhpUnhandledExceptionInspection */ |
|
| 51 | - self::$loggers[$logger]->pushHandler( |
|
| 52 | - new StreamHandler((self::$storagePathFunction)() . '/logs/' . $logger . '.log')); |
|
| 53 | - } |
|
| 54 | - self::$loggers[$logger]->log($type, $message); |
|
| 41 | + if (self::$testing && $logger !== Logs::TESTING) { |
|
| 42 | + //do nothing |
|
| 43 | + return; |
|
| 44 | + } |
|
| 45 | + Logs::ensureValidValue($logger); |
|
| 46 | + if (!array_key_exists($logger, self::$loggers)) { |
|
| 47 | + self::$loggers[$logger] = new Logger($logger); |
|
| 48 | + // InvalidArgumentException => stream is a string |
|
| 49 | + // Exception => path is static and it is ensured that it is valid |
|
| 50 | + /** @noinspection PhpUnhandledExceptionInspection */ |
|
| 51 | + self::$loggers[$logger]->pushHandler( |
|
| 52 | + new StreamHandler((self::$storagePathFunction)() . '/logs/' . $logger . '.log')); |
|
| 53 | + } |
|
| 54 | + self::$loggers[$logger]->log($type, $message); |
|
| 55 | 55 | } |
| 56 | 56 | //</editor-fold desc="Public Methods"> |
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public static function ensureValidValue($value, bool $strict = true): void |
| 36 | 36 | { |
| 37 | - if (!self::isValidValue($value, $strict)) { |
|
| 38 | - throw new ValueNotValid($value, get_called_class()); |
|
| 39 | - } |
|
| 37 | + if (!self::isValidValue($value, $strict)) { |
|
| 38 | + throw new ValueNotValid($value, get_called_class()); |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public static function getNames(): array |
| 47 | 47 | { |
| 48 | - return array_keys(self::getConstants()); |
|
| 48 | + return array_keys(self::getConstants()); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -57,20 +57,20 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public static function getValue(string $name, bool $strict = false) |
| 59 | 59 | { |
| 60 | - $constants = self::getConstants(); |
|
| 61 | - if ($strict) { |
|
| 62 | - if (array_key_exists($name, $constants)) { |
|
| 63 | - return $constants[$name]; |
|
| 64 | - } |
|
| 65 | - } else { |
|
| 66 | - $mapping = self::getCaseMapping(); |
|
| 67 | - $key = strtolower($name); |
|
| 68 | - if (array_key_exists($key, $mapping)) { |
|
| 69 | - return $constants[$mapping[$key]]; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - throw new ValueNotValid($name, get_called_class(), "getValues"); |
|
| 60 | + $constants = self::getConstants(); |
|
| 61 | + if ($strict) { |
|
| 62 | + if (array_key_exists($name, $constants)) { |
|
| 63 | + return $constants[$name]; |
|
| 64 | + } |
|
| 65 | + } else { |
|
| 66 | + $mapping = self::getCaseMapping(); |
|
| 67 | + $key = strtolower($name); |
|
| 68 | + if (array_key_exists($key, $mapping)) { |
|
| 69 | + return $constants[$mapping[$key]]; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + throw new ValueNotValid($name, get_called_class(), "getValues"); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public static function getValues(): array |
| 81 | 81 | { |
| 82 | - return array_values(self::getConstants()); |
|
| 82 | + return array_values(self::getConstants()); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -90,14 +90,14 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public static function isValidName(string $name, bool $strict = false): bool |
| 92 | 92 | { |
| 93 | - $constants = self::getConstants(); |
|
| 93 | + $constants = self::getConstants(); |
|
| 94 | 94 | |
| 95 | - if ($strict) { |
|
| 96 | - return array_key_exists($name, $constants); |
|
| 97 | - } |
|
| 95 | + if ($strict) { |
|
| 96 | + return array_key_exists($name, $constants); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - $keys = array_map('strtolower', array_keys($constants)); |
|
| 100 | - return in_array(strtolower($name), $keys); |
|
| 99 | + $keys = array_map('strtolower', array_keys($constants)); |
|
| 100 | + return in_array(strtolower($name), $keys); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public static function isValidValue($value, bool $strict = true): bool |
| 110 | 110 | { |
| 111 | - $values = self::getValues(); |
|
| 112 | - return in_array($value, $values, $strict); |
|
| 111 | + $values = self::getValues(); |
|
| 112 | + return in_array($value, $values, $strict); |
|
| 113 | 113 | } |
| 114 | 114 | //</editor-fold desc="Public Methods"> |
| 115 | 115 | |
@@ -121,17 +121,17 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | private static function getCaseMapping(): array |
| 123 | 123 | { |
| 124 | - if (self::$constCacheArrayCaseMapping == NULL) { |
|
| 125 | - self::$constCacheArrayCaseMapping = []; |
|
| 126 | - } |
|
| 127 | - $calledClass = get_called_class(); |
|
| 128 | - if (!array_key_exists($calledClass, self::$constCacheArrayCaseMapping)) { |
|
| 129 | - self::$constCacheArrayCaseMapping[$calledClass] = []; |
|
| 130 | - foreach (self::getNames() as $name) { |
|
| 131 | - self::$constCacheArrayCaseMapping[$calledClass][strtolower($name)] = $name; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - return self::$constCacheArrayCaseMapping[$calledClass]; |
|
| 124 | + if (self::$constCacheArrayCaseMapping == NULL) { |
|
| 125 | + self::$constCacheArrayCaseMapping = []; |
|
| 126 | + } |
|
| 127 | + $calledClass = get_called_class(); |
|
| 128 | + if (!array_key_exists($calledClass, self::$constCacheArrayCaseMapping)) { |
|
| 129 | + self::$constCacheArrayCaseMapping[$calledClass] = []; |
|
| 130 | + foreach (self::getNames() as $name) { |
|
| 131 | + self::$constCacheArrayCaseMapping[$calledClass][strtolower($name)] = $name; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + return self::$constCacheArrayCaseMapping[$calledClass]; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** @noinspection PhpDocMissingThrowsInspection */ //ReflectionException |
@@ -141,19 +141,19 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | private static function getConstants(): array |
| 143 | 143 | { |
| 144 | - if (self::$constCacheArray == NULL) { |
|
| 145 | - self::$constCacheArray = []; |
|
| 146 | - } |
|
| 147 | - $calledClass = get_called_class(); |
|
| 148 | - if (!array_key_exists($calledClass, self::$constCacheArray)) { |
|
| 149 | - // ReflectionException => whe know that calledClass is a valid class since it is the result of get_called_class |
|
| 150 | - /** @noinspection PhpUnhandledExceptionInspection */ |
|
| 151 | - $reflect = new \ReflectionClass($calledClass); |
|
| 152 | - $array = $reflect->getConstants(); |
|
| 153 | - asort($array); |
|
| 154 | - self::$constCacheArray[$calledClass] = $array; |
|
| 155 | - } |
|
| 156 | - return self::$constCacheArray[$calledClass]; |
|
| 144 | + if (self::$constCacheArray == NULL) { |
|
| 145 | + self::$constCacheArray = []; |
|
| 146 | + } |
|
| 147 | + $calledClass = get_called_class(); |
|
| 148 | + if (!array_key_exists($calledClass, self::$constCacheArray)) { |
|
| 149 | + // ReflectionException => whe know that calledClass is a valid class since it is the result of get_called_class |
|
| 150 | + /** @noinspection PhpUnhandledExceptionInspection */ |
|
| 151 | + $reflect = new \ReflectionClass($calledClass); |
|
| 152 | + $array = $reflect->getConstants(); |
|
| 153 | + asort($array); |
|
| 154 | + self::$constCacheArray[$calledClass] = $array; |
|
| 155 | + } |
|
| 156 | + return self::$constCacheArray[$calledClass]; |
|
| 157 | 157 | } |
| 158 | 158 | //</editor-fold desc="Private Methods"> |
| 159 | 159 | } |
| 160 | 160 | \ No newline at end of file |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function boot() |
| 46 | 46 | { |
| 47 | - include __DIR__ . '/../routes.php'; |
|
| 47 | + include __DIR__ . '/../routes.php'; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** @noinspection PhpDocMissingThrowsInspection */ //\Doctrine\DBAL\DBALException |
@@ -55,42 +55,42 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function register() |
| 57 | 57 | { |
| 58 | - //register middleware |
|
| 59 | - app()->routeMiddleware(['auth' => Authenticate::class]); |
|
| 58 | + //register middleware |
|
| 59 | + app()->routeMiddleware(['auth' => Authenticate::class]); |
|
| 60 | 60 | |
| 61 | - $this->app->singleton( |
|
| 62 | - ExceptionHandler::class, |
|
| 63 | - Handler::class |
|
| 64 | - ); |
|
| 61 | + $this->app->singleton( |
|
| 62 | + ExceptionHandler::class, |
|
| 63 | + Handler::class |
|
| 64 | + ); |
|
| 65 | 65 | |
| 66 | - if ($this->app->environment() !== 'production') { |
|
| 67 | - if (class_exists('\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider')) { |
|
| 68 | - $this->app->register('\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider'); |
|
| 69 | - } |
|
| 70 | - } |
|
| 66 | + if ($this->app->environment() !== 'production') { |
|
| 67 | + if (class_exists('\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider')) { |
|
| 68 | + $this->app->register('\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider'); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** @noinspection PhpUnhandledExceptionInspection */ // \Doctrine\DBAL\DBALException datetime is a valid type |
|
| 73 | - Type::overrideType('datetime', UTCDateTimeType::class); |
|
| 72 | + /** @noinspection PhpUnhandledExceptionInspection */ // \Doctrine\DBAL\DBALException datetime is a valid type |
|
| 73 | + Type::overrideType('datetime', UTCDateTimeType::class); |
|
| 74 | 74 | |
| 75 | - $this->app->register(LumenServiceProvider::class); |
|
| 76 | - $this->app->register(DoctrineServiceProvider::class); |
|
| 77 | - $this->app->register(GedmoExtensionsServiceProvider::class); |
|
| 78 | - $this->app->register(JwtAuthGuardServiceProvider::class); |
|
| 75 | + $this->app->register(LumenServiceProvider::class); |
|
| 76 | + $this->app->register(DoctrineServiceProvider::class); |
|
| 77 | + $this->app->register(GedmoExtensionsServiceProvider::class); |
|
| 78 | + $this->app->register(JwtAuthGuardServiceProvider::class); |
|
| 79 | 79 | |
| 80 | - $this->app->singleton(DynamicServiceLoadingServiceInterface::class, function (Container $app) { |
|
| 81 | - return new DynamicServiceLoadingService($app); |
|
| 82 | - }); |
|
| 80 | + $this->app->singleton(DynamicServiceLoadingServiceInterface::class, function (Container $app) { |
|
| 81 | + return new DynamicServiceLoadingService($app); |
|
| 82 | + }); |
|
| 83 | 83 | |
| 84 | - $this->app->singleton(RankingSystemServiceInterface::class, function (Container $app) { |
|
| 85 | - return new RankingSystemService($app->make(DynamicServiceLoadingServiceInterface::class), |
|
| 86 | - $app->make(EntityManagerInterface::class)); |
|
| 87 | - }); |
|
| 84 | + $this->app->singleton(RankingSystemServiceInterface::class, function (Container $app) { |
|
| 85 | + return new RankingSystemService($app->make(DynamicServiceLoadingServiceInterface::class), |
|
| 86 | + $app->make(EntityManagerInterface::class)); |
|
| 87 | + }); |
|
| 88 | 88 | |
| 89 | - $this->app->singleton(EloRankingInterface::class, function (Container $app) { |
|
| 90 | - $timeService = new RecursiveEndStartTimeService(); |
|
| 91 | - $entityComparer = new EntityComparerByTimeStartTimeAndLocalIdentifier($timeService); |
|
| 92 | - return new EloRanking($app->make(EntityManagerInterface::class), $timeService, $entityComparer); |
|
| 93 | - }); |
|
| 89 | + $this->app->singleton(EloRankingInterface::class, function (Container $app) { |
|
| 90 | + $timeService = new RecursiveEndStartTimeService(); |
|
| 91 | + $entityComparer = new EntityComparerByTimeStartTimeAndLocalIdentifier($timeService); |
|
| 92 | + return new EloRanking($app->make(EntityManagerInterface::class), $timeService, $entityComparer); |
|
| 93 | + }); |
|
| 94 | 94 | } |
| 95 | 95 | //</editor-fold desc="Public Methods"> |
| 96 | 96 | } |
| 97 | 97 | \ No newline at end of file |