@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | |
121 | 121 | $migration = new Migration(new Uri($dbConnection), $this->workdir . "/db"); |
122 | 122 | $migration->registerDatabase("mysql", MySqlDatabase::class); |
123 | - $migration->addCallbackProgress(function ($cmd, $version) { |
|
123 | + $migration->addCallbackProgress(function($cmd, $version) { |
|
124 | 124 | echo "Doing $cmd, $version\n"; |
125 | 125 | }); |
126 | 126 | |
127 | 127 | $argumentList = $this->extractArguments($arguments); |
128 | 128 | |
129 | - $exec['reset'] = function () use ($migration, $argumentList) { |
|
130 | - if (!$argumentList["--yes"]) { |
|
129 | + $exec[ 'reset' ] = function() use ($migration, $argumentList) { |
|
130 | + if (!$argumentList[ "--yes" ]) { |
|
131 | 131 | throw new Exception("Reset require the argument --yes"); |
132 | 132 | } |
133 | 133 | $migration->prepareEnvironment(); |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | }; |
136 | 136 | |
137 | 137 | |
138 | - $exec["update"] = function () use ($migration, $argumentList) { |
|
139 | - $migration->update($argumentList["--up-to"], $argumentList["--force"]); |
|
138 | + $exec[ "update" ] = function() use ($migration, $argumentList) { |
|
139 | + $migration->update($argumentList[ "--up-to" ], $argumentList[ "--force" ]); |
|
140 | 140 | }; |
141 | 141 | |
142 | - if (isset($exec[$argumentList['command']])) { |
|
143 | - $exec[$argumentList['command']](); |
|
142 | + if (isset($exec[ $argumentList[ 'command' ] ])) { |
|
143 | + $exec[ $argumentList[ 'command' ] ](); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | |
159 | 159 | $start = 0; |
160 | 160 | if ($hasCmd) { |
161 | - $ret['command'] = isset($arguments[0]) ? $arguments[0] : null; |
|
161 | + $ret[ 'command' ] = isset($arguments[ 0 ]) ? $arguments[ 0 ] : null; |
|
162 | 162 | $start = 1; |
163 | 163 | } |
164 | 164 | |
165 | - for ($i=$start; $i < count($arguments); $i++) { |
|
166 | - $args = explode("=", $arguments[$i]); |
|
167 | - $ret[$args[0]] = isset($args[1]) ? $args[1] : true; |
|
165 | + for ($i = $start; $i < count($arguments); $i++) { |
|
166 | + $args = explode("=", $arguments[ $i ]); |
|
167 | + $ret[ $args[ 0 ] ] = isset($args[ 1 ]) ? $args[ 1 ] : true; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | return $ret; |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | // get exit status |
88 | 88 | preg_match('/[0-9]+$/', $completeOutput, $matches); |
89 | 89 | |
90 | - $exitStatus = intval($matches[0]); |
|
90 | + $exitStatus = intval($matches[ 0 ]); |
|
91 | 91 | // if ($exitStatus !== 0) { |
92 | 92 | // exit($exitStatus); |
93 | 93 | // } |
94 | 94 | |
95 | 95 | // return exit status and intended output |
96 | - return array ( |
|
96 | + return array( |
|
97 | 97 | 'exit_status' => $exitStatus, |
98 | - 'output' => str_replace("Exit status : " . $matches[0], '', $completeOutput) |
|
98 | + 'output' => str_replace("Exit status : " . $matches[ 0 ], '', $completeOutput) |
|
99 | 99 | ); |
100 | 100 | } |
101 | 101 | |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | */ |
110 | 110 | protected function replaceVariables($variableValue) |
111 | 111 | { |
112 | - $args = []; |
|
112 | + $args = [ ]; |
|
113 | 113 | if (preg_match_all("/%[\\w\\d]+%/", $variableValue, $args)) { |
114 | - foreach ($args[0] as $arg) { |
|
114 | + foreach ($args[ 0 ] as $arg) { |
|
115 | 115 | $variableValue = str_replace( |
116 | 116 | $arg, |
117 | - Psr11::container()->get(substr($arg,1, -1)), |
|
117 | + Psr11::container()->get(substr($arg, 1, -1)), |
|
118 | 118 | $variableValue |
119 | 119 | ); |
120 | 120 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | public function execute($workdir, $namespace, $composerName, $phpVersion, $mysqlConnection, $timezone) |
14 | 14 | { |
15 | 15 | $directory = new RecursiveDirectoryIterator($workdir); |
16 | - $filter = new RecursiveCallbackFilterIterator($directory, function ($current/*, $key, $iterator*/) { |
|
16 | + $filter = new RecursiveCallbackFilterIterator($directory, function($current/*, $key, $iterator*/) { |
|
17 | 17 | // Skip hidden files and directories. |
18 | - if ($current->getFilename()[0] === '.') { |
|
18 | + if ($current->getFilename()[ 0 ] === '.') { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | if ($current->isDir()) { |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | // Replace MySQL Connection |
52 | - $files = [ 'config/config-dev.php', 'config/config-homolog.php' , 'config/config-live.php', 'config/config-test.php']; |
|
52 | + $files = [ 'config/config-dev.php', 'config/config-homolog.php', 'config/config-live.php', 'config/config-test.php' ]; |
|
53 | 53 | foreach ($files as $file) { |
54 | 54 | $contents = file_get_contents("$workdir/$file"); |
55 | - $contents = str_replace( 'super_secret_key', JwtWrapper::generateSecret(64), $contents); |
|
55 | + $contents = str_replace('super_secret_key', JwtWrapper::generateSecret(64), $contents); |
|
56 | 56 | $contents = str_replace('mysql://root:password@mysql-container/database', "$mysqlConnection", $contents); |
57 | 57 | file_put_contents( |
58 | 58 | "$workdir/$file", |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $metadata = $this->createcreateUserMetadata($user); |
74 | 74 | |
75 | 75 | $response->getResponseBag()->serializationRule(ResponseBag::SINGLE_OBJECT); |
76 | - $response->write(['token' => $this->createToken($metadata)]); |
|
77 | - $response->write(['data' => $metadata]); |
|
76 | + $response->write([ 'token' => $this->createToken($metadata) ]); |
|
77 | + $response->write([ 'data' => $metadata ]); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | { |
117 | 117 | $result = $this->requireAuthenticated(null, true); |
118 | 118 | |
119 | - $diff = ($result["exp"] - time()) / 60; |
|
119 | + $diff = ($result[ "exp" ] - time())/60; |
|
120 | 120 | |
121 | 121 | if ($diff > 5) { |
122 | 122 | throw new Error401Exception("You only can refresh the token 5 minutes before expire"); |
123 | 123 | } |
124 | 124 | |
125 | 125 | $users = Psr11::container()->get('LOGIN'); |
126 | - $user = $users->getById(new Literal("X'" . str_replace("-", "", $result["data"]["userid"]) . "'")); |
|
126 | + $user = $users->getById(new Literal("X'" . str_replace("-", "", $result[ "data" ][ "userid" ]) . "'")); |
|
127 | 127 | |
128 | - $response->write([ "token" => $this->createToken($this->createcreateUserMetadata($user))]); |
|
128 | + $response->write([ "token" => $this->createToken($this->createcreateUserMetadata($user)) ]); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @throws KeyNotFoundException |
22 | 22 | * @throws InvalidArgumentException |
23 | 23 | */ |
24 | - public function createToken($properties = []) |
|
24 | + public function createToken($properties = [ ]) |
|
25 | 25 | { |
26 | 26 | $jwt = Psr11::container()->get('JWT_WRAPPER'); |
27 | 27 | $jwtData = $jwt->createJwtData($properties, 1800); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | if ($fullToken) { |
44 | 44 | return $tokenInfo; |
45 | 45 | } else { |
46 | - return $tokenInfo['data']; |
|
46 | + return $tokenInfo[ 'data' ]; |
|
47 | 47 | } |
48 | 48 | } catch (Exception $ex) { |
49 | 49 | throw new Error401Exception($ex->getMessage()); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function requireRole($role, $token = null) |
61 | 61 | { |
62 | 62 | $data = $this->requireAuthenticated($token); |
63 | - if ($data['role'] !== $role) { |
|
63 | + if ($data[ 'role' ] !== $role) { |
|
64 | 64 | throw new Error401Exception('Insufficient privileges - ' . print_r($data, true)); |
65 | 65 | } |
66 | 66 | return $data; |