@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $this->app->bind(UserAuthenticationInterface::class, UserAuthentication::class); |
106 | 106 | |
107 | 107 | // Configuration |
108 | - $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
108 | + $this->app->bind(Configuration::class, function(ContainerInterface $app) { |
|
109 | 109 | return new Configuration($app->get(Config::class)->get('oauth2', [])); |
110 | 110 | }); |
111 | 111 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function addRoutes(Router $router): void |
166 | 166 | { |
167 | - $router->group('/oauth2', function (Router $router) { |
|
167 | + $router->group('/oauth2', function(Router $router) { |
|
168 | 168 | $router->post('/token', AccessTokenRequestHandler::class, 'oauth2_access_token'); |
169 | 169 | $router->add('/authorize', AuthorizationRequestHandler::class, ['GET', 'POST'], 'oauth2_authorization_code'); |
170 | 170 | $router->post('/revocation', TokenRevocationRequestHandler::class, 'oauth2_revoke_access_token'); |
@@ -93,8 +93,7 @@ discard block |
||
93 | 93 | * @class OAuth2ServiceProvider |
94 | 94 | * @package Platine\App\Provider |
95 | 95 | */ |
96 | -class OAuth2ServiceProvider extends ServiceProvider |
|
97 | -{ |
|
96 | +class OAuth2ServiceProvider extends ServiceProvider { |
|
98 | 97 | /** |
99 | 98 | * {@inheritdoc} |
100 | 99 | */ |
@@ -105,7 +104,7 @@ discard block |
||
105 | 104 | $this->app->bind(UserAuthenticationInterface::class, UserAuthentication::class); |
106 | 105 | |
107 | 106 | // Configuration |
108 | - $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
107 | + $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
109 | 108 | return new Configuration($app->get(Config::class)->get('oauth2', [])); |
110 | 109 | }); |
111 | 110 | |
@@ -134,10 +133,10 @@ discard block |
||
134 | 133 | $cfg = $this->app->get(Configuration::class); |
135 | 134 | $grants = $cfg->getGrants(); |
136 | 135 | $serverGrants = []; |
137 | - foreach ($grants as $grant) { |
|
138 | - if ($this->app->has($grant)) { |
|
136 | + foreach ($grants as $grant) { |
|
137 | + if ($this->app->has($grant)) { |
|
139 | 138 | $serverGrants[] = $this->app->get($grant); |
140 | - } else { |
|
139 | + } else { |
|
141 | 140 | $serverGrants[] = new $grant(); |
142 | 141 | } |
143 | 142 | } |
@@ -164,7 +163,7 @@ discard block |
||
164 | 163 | */ |
165 | 164 | public function addRoutes(Router $router): void |
166 | 165 | { |
167 | - $router->group('/oauth2', function (Router $router) { |
|
166 | + $router->group('/oauth2', function (Router $router) { |
|
168 | 167 | $router->post('/token', AccessTokenRequestHandler::class, 'oauth2_access_token'); |
169 | 168 | $router->add('/authorize', AuthorizationRequestHandler::class, ['GET', 'POST'], 'oauth2_authorization_code'); |
170 | 169 | $router->post('/revocation', TokenRevocationRequestHandler::class, 'oauth2_revoke_access_token'); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function register(): void |
71 | 71 | { |
72 | - $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
72 | + $this->app->bind(Configuration::class, function(ContainerInterface $app) { |
|
73 | 73 | /** @template T @var Config<T> $config */ |
74 | 74 | $config = $app->get(Config::class); |
75 | 75 | $driver = $config->get('database.default', 'default'); |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | return new Configuration($config->get('database.connections.' . $driver, [])); |
78 | 78 | }); |
79 | 79 | |
80 | - $this->app->share(Pool::class, function (ContainerInterface $app) { |
|
80 | + $this->app->share(Pool::class, function(ContainerInterface $app) { |
|
81 | 81 | return new Pool($app->get(Config::class)->get('database', [])); |
82 | 82 | }); |
83 | 83 | |
84 | - $this->app->share(Connection::class, function (ContainerInterface $app) { |
|
84 | + $this->app->share(Connection::class, function(ContainerInterface $app) { |
|
85 | 85 | return new Connection( |
86 | 86 | $app->get(Configuration::class), |
87 | 87 | $app->get(LoggerInterface::class) |
@@ -62,14 +62,13 @@ discard block |
||
62 | 62 | * @class DatabaseServiceProvider |
63 | 63 | * @package Platine\Framework\Service\Provider |
64 | 64 | */ |
65 | -class DatabaseServiceProvider extends ServiceProvider |
|
66 | -{ |
|
65 | +class DatabaseServiceProvider extends ServiceProvider { |
|
67 | 66 | /** |
68 | 67 | * {@inheritdoc} |
69 | 68 | */ |
70 | 69 | public function register(): void |
71 | 70 | { |
72 | - $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
71 | + $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
73 | 72 | /** @template T @var Config<T> $config */ |
74 | 73 | $config = $app->get(Config::class); |
75 | 74 | $driver = $config->get('database.default', 'default'); |
@@ -77,11 +76,11 @@ discard block |
||
77 | 76 | return new Configuration($config->get('database.connections.' . $driver, [])); |
78 | 77 | }); |
79 | 78 | |
80 | - $this->app->share(Pool::class, function (ContainerInterface $app) { |
|
79 | + $this->app->share(Pool::class, function (ContainerInterface $app) { |
|
81 | 80 | return new Pool($app->get(Config::class)->get('database', [])); |
82 | 81 | }); |
83 | 82 | |
84 | - $this->app->share(Connection::class, function (ContainerInterface $app) { |
|
83 | + $this->app->share(Connection::class, function (ContainerInterface $app) { |
|
85 | 84 | return new Connection( |
86 | 85 | $app->get(Configuration::class), |
87 | 86 | $app->get(LoggerInterface::class) |
@@ -66,7 +66,7 @@ |
||
66 | 66 | public function register(): void |
67 | 67 | { |
68 | 68 | $this->app->bind(AdapterInterface::class, OpenSSL::class); |
69 | - $this->app->bind(Encryption::class, function (ContainerInterface $app) { |
|
69 | + $this->app->bind(Encryption::class, function(ContainerInterface $app) { |
|
70 | 70 | $e = new Encryption($app->get(AdapterInterface::class)); |
71 | 71 | $e->setSecret($app->get(Config::class)->get('security.encryption.key', '')); |
72 | 72 |
@@ -58,15 +58,14 @@ |
||
58 | 58 | * @class EncryptionServiceProvider |
59 | 59 | * @package Platine\Framework\Service\Provider |
60 | 60 | */ |
61 | -class EncryptionServiceProvider extends ServiceProvider |
|
62 | -{ |
|
61 | +class EncryptionServiceProvider extends ServiceProvider { |
|
63 | 62 | /** |
64 | 63 | * {@inheritdoc} |
65 | 64 | */ |
66 | 65 | public function register(): void |
67 | 66 | { |
68 | 67 | $this->app->bind(AdapterInterface::class, OpenSSL::class); |
69 | - $this->app->bind(Encryption::class, function (ContainerInterface $app) { |
|
68 | + $this->app->bind(Encryption::class, function (ContainerInterface $app) { |
|
70 | 69 | $e = new Encryption($app->get(AdapterInterface::class)); |
71 | 70 | $e->setSecret($app->get(Config::class)->get('security.encryption.key', '')); |
72 | 71 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | DatabaseConfigLoader::class |
74 | 74 | ); |
75 | 75 | |
76 | - $this->app->share(AppDatabaseConfig::class, function (ContainerInterface $app) { |
|
76 | + $this->app->share(AppDatabaseConfig::class, function(ContainerInterface $app) { |
|
77 | 77 | $env = $app->get(Config::class)->get('app.env', ''); |
78 | 78 | return new AppDatabaseConfig($app->get(DatabaseConfigLoaderInterface::class), $env); |
79 | 79 | }); |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | * @class DatabaseConfigServiceProvider |
61 | 61 | * @package Platine\Framework\Service\Provider |
62 | 62 | */ |
63 | -class DatabaseConfigServiceProvider extends ServiceProvider |
|
64 | -{ |
|
63 | +class DatabaseConfigServiceProvider extends ServiceProvider { |
|
65 | 64 | /** |
66 | 65 | * {@inheritdoc} |
67 | 66 | */ |
@@ -73,7 +72,7 @@ discard block |
||
73 | 72 | DatabaseConfigLoader::class |
74 | 73 | ); |
75 | 74 | |
76 | - $this->app->share(AppDatabaseConfig::class, function (ContainerInterface $app) { |
|
75 | + $this->app->share(AppDatabaseConfig::class, function (ContainerInterface $app) { |
|
77 | 76 | $env = $app->get(Config::class)->get('app.env', ''); |
78 | 77 | return new AppDatabaseConfig($app->get(DatabaseConfigLoaderInterface::class), $env); |
79 | 78 | }); |
@@ -68,7 +68,7 @@ |
||
68 | 68 | */ |
69 | 69 | public function register(): void |
70 | 70 | { |
71 | - $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
71 | + $this->app->bind(Configuration::class, function(ContainerInterface $app) { |
|
72 | 72 | return new Configuration($app->get(Config::class)->get('lang', [])); |
73 | 73 | }); |
74 | 74 | $this->app->share(StorageInterface::class, MemoryStorage::class); |
@@ -61,14 +61,13 @@ |
||
61 | 61 | * @class LangServiceProvider |
62 | 62 | * @package Platine\Framework\Service\Provider |
63 | 63 | */ |
64 | -class LangServiceProvider extends ServiceProvider |
|
65 | -{ |
|
64 | +class LangServiceProvider extends ServiceProvider { |
|
66 | 65 | /** |
67 | 66 | * {@inheritdoc} |
68 | 67 | */ |
69 | 68 | public function register(): void |
70 | 69 | { |
71 | - $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
70 | + $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
72 | 71 | return new Configuration($app->get(Config::class)->get('lang', [])); |
73 | 72 | }); |
74 | 73 | $this->app->share(StorageInterface::class, MemoryStorage::class); |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * @class ServiceProvider |
58 | 58 | * @package Platine\Framework\Service |
59 | 59 | */ |
60 | -class ServiceProvider |
|
61 | -{ |
|
60 | +class ServiceProvider { |
|
62 | 61 | /** |
63 | 62 | * The Application instance |
64 | 63 | * @var Application |
@@ -81,8 +80,7 @@ discard block |
||
81 | 80 | * Create new instance |
82 | 81 | * @param Application $app |
83 | 82 | */ |
84 | - public function __construct(Application $app) |
|
85 | - { |
|
83 | + public function __construct(Application $app) { |
|
86 | 84 | $this->app = $app; |
87 | 85 | } |
88 | 86 |
@@ -128,10 +128,10 @@ |
||
128 | 128 | $name = $results['key']; |
129 | 129 | |
130 | 130 | $config = $this->loader->loadConfig([ |
131 | - 'name' => $name, |
|
132 | - 'module' => $module, |
|
133 | - 'env' => $this->env |
|
134 | - ]); |
|
131 | + 'name' => $name, |
|
132 | + 'module' => $module, |
|
133 | + 'env' => $this->env |
|
134 | + ]); |
|
135 | 135 | |
136 | 136 | if ($config === null) { |
137 | 137 | $this->loader->insertConfig([ |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * @template TDbConfigurationEntity as \Platine\Framework\Config\Model\Configuration |
58 | 58 | * @implements ArrayAccess<string, mixed> |
59 | 59 | */ |
60 | -class AppDatabaseConfig implements ArrayAccess |
|
61 | -{ |
|
60 | +class AppDatabaseConfig implements ArrayAccess { |
|
62 | 61 | /** |
63 | 62 | * The configuration loader to use |
64 | 63 | * @var DatabaseConfigLoaderInterface<TDbConfigurationEntity> |
@@ -82,8 +81,7 @@ discard block |
||
82 | 81 | * @param DatabaseConfigLoaderInterface<TDbConfigurationEntity> $loader the loader to use |
83 | 82 | * @param string $env the name of the environment |
84 | 83 | */ |
85 | - public function __construct(DatabaseConfigLoaderInterface $loader, string $env = '') |
|
86 | - { |
|
84 | + public function __construct(DatabaseConfigLoaderInterface $loader, string $env = '') { |
|
87 | 85 | $this->loader = $loader; |
88 | 86 | $this->env = $env; |
89 | 87 | } |
@@ -105,8 +103,7 @@ discard block |
||
105 | 103 | * not find the configuration item |
106 | 104 | * @return mixed |
107 | 105 | */ |
108 | - public function get(string $key, $default = null) |
|
109 | - { |
|
106 | + public function get(string $key, $default = null) { |
|
110 | 107 | $results = $this->parseKey($key); |
111 | 108 | $group = $results['group']; |
112 | 109 | |
@@ -133,7 +130,7 @@ discard block |
||
133 | 130 | 'env' => $this->env |
134 | 131 | ]); |
135 | 132 | |
136 | - if ($config === null) { |
|
133 | + if ($config === null) { |
|
137 | 134 | $this->loader->insertConfig([ |
138 | 135 | 'env' => $this->env, |
139 | 136 | 'module' => $module, |
@@ -142,7 +139,7 @@ discard block |
||
142 | 139 | 'value' => $this->getFormattedConfigValue($value), |
143 | 140 | 'type' => gettype($value) |
144 | 141 | ]); |
145 | - } else { |
|
142 | + } else { |
|
146 | 143 | $config->value = $this->getFormattedConfigValue($value); |
147 | 144 | $config->type = gettype($value); |
148 | 145 | |
@@ -215,16 +212,14 @@ discard block |
||
215 | 212 | /** |
216 | 213 | * {@inheritdoc} |
217 | 214 | */ |
218 | - public function offsetExists($key) |
|
219 | - { |
|
215 | + public function offsetExists($key) { |
|
220 | 216 | return $this->has($key); |
221 | 217 | } |
222 | 218 | |
223 | 219 | /** |
224 | 220 | * {@inheritdoc} |
225 | 221 | */ |
226 | - public function offsetGet($key) |
|
227 | - { |
|
222 | + public function offsetGet($key) { |
|
228 | 223 | return $this->get($key); |
229 | 224 | } |
230 | 225 | |
@@ -234,16 +229,14 @@ discard block |
||
234 | 229 | * @param mixed $value |
235 | 230 | * @return void |
236 | 231 | */ |
237 | - public function offsetSet($key, $value) |
|
238 | - { |
|
232 | + public function offsetSet($key, $value) { |
|
239 | 233 | $this->set($key, $value); |
240 | 234 | } |
241 | 235 | |
242 | 236 | /** |
243 | 237 | * {@inheritdoc} |
244 | 238 | */ |
245 | - public function offsetUnset($key) |
|
246 | - { |
|
239 | + public function offsetUnset($key) { |
|
247 | 240 | $this->set($key, null); |
248 | 241 | } |
249 | 242 | |
@@ -257,7 +250,7 @@ discard block |
||
257 | 250 | // If we've already loaded this collection, we will just bail out since we do |
258 | 251 | // not want to load it again. Once items are loaded a first time they will |
259 | 252 | // stay kept in memory within this class and not loaded from disk again. |
260 | - if (isset($this->items[$group])) { |
|
253 | + if (isset($this->items[$group])) { |
|
261 | 254 | return; |
262 | 255 | } |
263 | 256 | |
@@ -272,7 +265,7 @@ discard block |
||
272 | 265 | */ |
273 | 266 | protected function parseKey(string $key): array |
274 | 267 | { |
275 | - if (strpos($key, '.') === false) { |
|
268 | + if (strpos($key, '.') === false) { |
|
276 | 269 | throw new InvalidArgumentException(sprintf( |
277 | 270 | 'Invalid configuration key [%s] must have format module.name', |
278 | 271 | $key |
@@ -292,9 +285,8 @@ discard block |
||
292 | 285 | * @param mixed $value |
293 | 286 | * @return mixed |
294 | 287 | */ |
295 | - protected function getFormattedConfigValue($value) |
|
296 | - { |
|
297 | - if (is_array($value) || is_object($value)) { |
|
288 | + protected function getFormattedConfigValue($value) { |
|
289 | + if (is_array($value) || is_object($value)) { |
|
298 | 290 | return serialize($value); |
299 | 291 | } |
300 | 292 |
@@ -128,7 +128,7 @@ |
||
128 | 128 | ->query() |
129 | 129 | ->where('module')->is($group) |
130 | 130 | ->where('status')->is('Y') |
131 | - ->where(function (WhereStatement $where) use ($env) { |
|
131 | + ->where(function(WhereStatement $where) use ($env) { |
|
132 | 132 | $where->where('env')->is($env) |
133 | 133 | ->orWhere('env')->isNull(); |
134 | 134 | }); |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | * @package Platine\Framework\Config |
57 | 57 | * @implements DatabaseConfigLoaderInterface<Configuration> |
58 | 58 | */ |
59 | -class DatabaseConfigLoader implements DatabaseConfigLoaderInterface |
|
60 | -{ |
|
59 | +class DatabaseConfigLoader implements DatabaseConfigLoaderInterface { |
|
61 | 60 | /** |
62 | 61 | * The Repository instance |
63 | 62 | * @var ConfigurationRepositoryInterface<Configuration> |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | * Create new instance |
70 | 69 | * @param ConfigurationRepositoryInterface<Configuration> $repository |
71 | 70 | */ |
72 | - public function __construct(ConfigurationRepositoryInterface $repository) |
|
73 | - { |
|
71 | + public function __construct(ConfigurationRepositoryInterface $repository) { |
|
74 | 72 | $this->repository = $repository; |
75 | 73 | } |
76 | 74 | |
@@ -93,8 +91,7 @@ discard block |
||
93 | 91 | /** |
94 | 92 | * {@inheritdoc} |
95 | 93 | */ |
96 | - public function insertConfig(array $data) |
|
97 | - { |
|
94 | + public function insertConfig(array $data) { |
|
98 | 95 | $entity = $this->repository->create($data); |
99 | 96 | return $this->repository->insert($entity); |
100 | 97 | } |
@@ -128,7 +125,7 @@ discard block |
||
128 | 125 | ->query() |
129 | 126 | ->where('module')->is($group) |
130 | 127 | ->where('status')->is('Y') |
131 | - ->where(function (WhereStatement $where) use ($env) { |
|
128 | + ->where(function (WhereStatement $where) use ($env) { |
|
132 | 129 | $where->where('env')->is($env) |
133 | 130 | ->orWhere('env')->isNull(); |
134 | 131 | }); |
@@ -138,10 +135,10 @@ discard block |
||
138 | 135 | $results = $query->all(); |
139 | 136 | |
140 | 137 | $items = []; |
141 | - foreach ($results as $result) { |
|
138 | + foreach ($results as $result) { |
|
142 | 139 | /** @var string $name */ |
143 | 140 | $name = $result->name; |
144 | - if (!empty($name)) { |
|
141 | + if (!empty($name)) { |
|
145 | 142 | $items[$name] = ConfigUtil::convertToDataType( |
146 | 143 | $result->value, |
147 | 144 | (string) $result->type |
@@ -71,19 +71,19 @@ |
||
71 | 71 | 'updated_at' => '?date', |
72 | 72 | ]); |
73 | 73 | |
74 | - $mapper->filter('status', function (Query $q, $value) { |
|
74 | + $mapper->filter('status', function(Query $q, $value) { |
|
75 | 75 | $q->where('status')->is($value); |
76 | 76 | }); |
77 | 77 | |
78 | - $mapper->filter('env', function (Query $q, $value) { |
|
78 | + $mapper->filter('env', function(Query $q, $value) { |
|
79 | 79 | $q->where('env')->is($value); |
80 | 80 | }); |
81 | 81 | |
82 | - $mapper->filter('module', function (Query $q, $value) { |
|
82 | + $mapper->filter('module', function(Query $q, $value) { |
|
83 | 83 | $q->where('module')->is($value); |
84 | 84 | }); |
85 | 85 | |
86 | - $mapper->filter('type', function (Query $q, $value) { |
|
86 | + $mapper->filter('type', function(Query $q, $value) { |
|
87 | 87 | $q->where('type')->is($value); |
88 | 88 | }); |
89 | 89 | } |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | * @package Platine\Framework\Config\Model |
57 | 57 | * @extends Entity<Configuration> |
58 | 58 | */ |
59 | -class Configuration extends Entity |
|
60 | -{ |
|
59 | +class Configuration extends Entity { |
|
61 | 60 | /** |
62 | 61 | * |
63 | 62 | * @param EntityMapperInterface<Configuration> $mapper |
@@ -71,19 +70,19 @@ discard block |
||
71 | 70 | 'updated_at' => '?date', |
72 | 71 | ]); |
73 | 72 | |
74 | - $mapper->filter('status', function (Query $q, $value) { |
|
73 | + $mapper->filter('status', function (Query $q, $value) { |
|
75 | 74 | $q->where('status')->is($value); |
76 | 75 | }); |
77 | 76 | |
78 | - $mapper->filter('env', function (Query $q, $value) { |
|
77 | + $mapper->filter('env', function (Query $q, $value) { |
|
79 | 78 | $q->where('env')->is($value); |
80 | 79 | }); |
81 | 80 | |
82 | - $mapper->filter('module', function (Query $q, $value) { |
|
81 | + $mapper->filter('module', function (Query $q, $value) { |
|
83 | 82 | $q->where('module')->is($value); |
84 | 83 | }); |
85 | 84 | |
86 | - $mapper->filter('type', function (Query $q, $value) { |
|
85 | + $mapper->filter('type', function (Query $q, $value) { |
|
87 | 86 | $q->where('type')->is($value); |
88 | 87 | }); |
89 | 88 | } |