Skip to content
This repository was archived by the owner on Aug 2, 2024. It is now read-only.

Commit b06d384

Browse files
author
Quinten Justus
committed
- Fixed DatabaseController error
- Formatting & code clean up - Merge branch 'master' of github.com:Protoqol/Prequel
2 parents 68e429a + 15cd3cb commit b06d384

34 files changed

+653
-700
lines changed

.github/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
</a>
2828
</p>
2929

30-
## Development temporarily on hold
31-
3230
#### [TL;DR? Test Prequel here!](https://prequel.protoqol.xyz/prequel)
3331

3432
#### What is Prequel exactly?

composer.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
{
2-
"name": "protoqol/prequel",
3-
"description": "Clear and concise database management.",
4-
"type": "library",
5-
"license": "MIT",
6-
"authors": [
2+
"name" : "protoqol/prequel",
3+
"description" : "Clear and concise database management.",
4+
"type" : "library",
5+
"license" : "MIT",
6+
"authors" : [
77
{
8-
"name": "Quinten Schorsij",
8+
"name" : "Quinten Schorsij",
99
"email": "quinten@protoqol.xyz"
1010
}
1111
],
12-
"minimum-stability": "stable",
13-
"require": {
14-
"php": "^7.1",
12+
"minimum-stability" : "stable",
13+
"require" : {
14+
"php" : "^7.1",
1515
"laravel/framework": ">=5.6"
1616
},
17-
"extra": {
17+
"extra" : {
1818
"laravel": {
1919
"providers": [
2020
"Protoqol\\Prequel\\PrequelServiceProvider"
2121
]
2222
}
2323
},
24-
"require-dev": {
24+
"require-dev" : {
2525
"orchestra/testbench": "^3.7",
26-
"phpmd/phpmd": "^2.6"
26+
"phpmd/phpmd" : "^2.6"
2727
},
28-
"autoload": {
28+
"autoload" : {
2929
"psr-4": {
3030
"Protoqol\\Prequel\\": "src"
3131
}
3232
},
33-
"autoload-dev": {
33+
"autoload-dev" : {
3434
"psr-4": {
3535
"Protoqol\\Prequel\\Tests\\": "tests/"
3636
}
3737
},
38-
"scripts": {
38+
"scripts" : {
3939
"phpins": [
4040
"./vendor/bin/phpinsights"
4141
],
42-
"phpmd": [
42+
"phpmd" : [
4343
"phpmd src html cleancode,codesize,controversial,design,naming,unusedcode > public/phpmd.html"
4444
],
45-
"test": [
45+
"test" : [
4646
"phpunit"
4747
]
4848
},
4949
"scripts-descriptions": {
5050
"phpins": "Runs nunomaduro's PHPInsights. This gives you a report about the current code quality.",
51-
"phpmd": "Runs PHPMD based on original configuration. You can find the new mess detector report at http://localhost/vendor/prequel/phpmd.html Note that 'Avoid using static access to class' errors should be ignored.",
52-
"test": "Runs the default PHPUnit test suite configured in phpunit.xml"
51+
"phpmd" : "Runs PHPMD based on original configuration. You can find the new mess detector report at http://localhost/vendor/prequel/phpmd.html Note that 'Avoid using static access to class' errors should be ignored.",
52+
"test" : "Runs the default PHPUnit test suite configured in phpunit.xml"
5353
}
5454
}

resources/assets/js/components/Dashboard/Dashboard.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
</template>
66

77
<script>
8-
import Management from './DashboardElements/Management'
8+
import Management from './DashboardElements/Management';
99
1010
export default {
11-
name : 'Dashboard',
12-
components: { Management },
13-
}
11+
name: 'Dashboard',
12+
components: {Management},
13+
};
1414
1515
</script>
1616

resources/assets/js/components/Dashboard/DashboardElements/Migrations.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
return {
3030
migrations: {
3131
pending: 0,
32-
total : 0,
32+
total: 0,
3333
},
3434
};
3535
},

resources/assets/js/components/Dashboard/DashboardElements/Settings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<!-- @TODO edit config -->
2+
<!-- @TODO edit config -->
33
</template>
44

55
<script>

resources/assets/js/components/Dashboard/DashboardElements/StatusDisplay.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<script>
1414
export default {
15-
name : 'StatusDisplay',
15+
name: 'StatusDisplay',
1616
props: ['header', 'value', 'unit'],
1717
};
1818
</script>

src/App/AppStatus.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,38 @@
88

99
/**
1010
* Class AppStatus
11+
*
1112
* @package Protoqol\Prequel\App
1213
*/
1314
class AppStatus
1415
{
1516

1617
/**
1718
* Holds Prequel's database connection.
19+
*
1820
* @var \Illuminate\Database\Connection
1921
*/
2022
private $connection;
2123

2224
/**
2325
* Holds database traverser instance.
26+
*
2427
* @var \Protoqol\Prequel\Database\DatabaseTraverser $traverser
2528
*/
2629
private $traverser;
2730

2831
/**
2932
* AppStatus constructor.
3033
*/
31-
public function __construct()
32-
{
34+
public function __construct() {
3335
$this->traverser = new DatabaseTraverser();
3436
$this->connection = (new DatabaseConnector())->getConnection();
3537
}
3638

3739
/**
3840
* @return array
3941
*/
40-
public function getStatus(): array
41-
{
42+
public function getStatus() : array {
4243
return [
4344
'migrations' => (new MigrationAction('', ''))->pending(),
4445
'serverInfo' => $this->serverInfo(),
@@ -48,33 +49,33 @@ public function getStatus(): array
4849

4950
/**
5051
* Get server info.
52+
*
5153
* @return array
5254
*/
53-
private function serverInfo(): array
54-
{
55+
private function serverInfo() : array {
5556
return $this->connection->getServerInfo();
5657
}
5758

5859
/**
5960
* Check database permissions for current user.
61+
*
6062
* @return array
6163
*/
62-
public function userPermissions(): array
63-
{
64+
public function userPermissions() : array {
6465

6566
$grants = $this->connection->getGrants();
66-
$privs = (string)array_values($grants)[0];
67+
$privs = (string) array_values($grants)[0];
6768
$permissions = [];
6869

6970
// If anyone seeing this has a better way of checking this, be my guest!
70-
$permissions['SELECT'] = (bool)preg_match('(SELECT)', $privs);
71-
$permissions['INSERT'] = (bool)preg_match('(INSERT)', $privs);
72-
$permissions['UPDATE'] = (bool)preg_match('(UPDATE)', $privs);
73-
$permissions['DELETE'] = (bool)preg_match('(DELETE)', $privs);
74-
$permissions['FILE'] = (bool)preg_match('(FILE)', $privs);
75-
$permissions['CREATE'] = (bool)preg_match('(CREATE)', $privs);
76-
$permissions['DROP'] = (bool)preg_match('(DROP)', $privs);
77-
$permissions['ALTER'] = (bool)preg_match('(ALTER)', $privs);
71+
$permissions['SELECT'] = (bool) preg_match('(SELECT)', $privs);
72+
$permissions['INSERT'] = (bool) preg_match('(INSERT)', $privs);
73+
$permissions['UPDATE'] = (bool) preg_match('(UPDATE)', $privs);
74+
$permissions['DELETE'] = (bool) preg_match('(DELETE)', $privs);
75+
$permissions['FILE'] = (bool) preg_match('(FILE)', $privs);
76+
$permissions['CREATE'] = (bool) preg_match('(CREATE)', $privs);
77+
$permissions['DROP'] = (bool) preg_match('(DROP)', $privs);
78+
$permissions['ALTER'] = (bool) preg_match('(ALTER)', $privs);
7879
$permissions['HAS_ALL'] = true;
7980

8081
// Check if user has all needed permissions

src/App/ConfigWriter.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,16 @@
2424
class ConfigWriter
2525
{
2626

27-
public function toFile(string $filePath, array $newValues, bool $useValidation = true): string
28-
{
27+
/**
28+
* Write to config file
29+
*
30+
* @param string $filePath
31+
* @param array $newValues
32+
* @param bool $useValidation
33+
*
34+
* @return string
35+
*/
36+
public function toFile(string $filePath, array $newValues, bool $useValidation = true) : string {
2937
$contents = file_get_contents($filePath);
3038

3139
try {
@@ -38,8 +46,7 @@ public function toFile(string $filePath, array $newValues, bool $useValidation =
3846
return $contents;
3947
}
4048

41-
public function toContent(string $contents, array $newValues, bool $useValidation = true): string
42-
{
49+
public function toContent(string $contents, array $newValues, bool $useValidation = true) : string {
4350
$contents = $this->parseContent($contents, $newValues);
4451

4552
if (!$useValidation) {
@@ -57,7 +64,7 @@ public function toContent(string $contents, array $newValues, bool $useValidatio
5764
throw new Exception(sprintf('Unable to rewrite key "%s" in config, does it exist?', $key));
5865
}
5966

60-
$array = $array[$part];
67+
$array = $array[ $part ];
6168
}
6269
$actualValue = $array;
6370

@@ -69,8 +76,7 @@ public function toContent(string $contents, array $newValues, bool $useValidatio
6976
return $contents;
7077
}
7178

72-
protected function parseContent(string $contents, array $newValues): string
73-
{
79+
protected function parseContent(string $contents, array $newValues) : string {
7480
$result = $contents;
7581

7682
foreach ($newValues as $path => $value) {
@@ -80,8 +86,7 @@ protected function parseContent(string $contents, array $newValues): string
8086
return $result;
8187
}
8288

83-
protected function parseContentValue(string $contents, string $path, $value): string
84-
{
89+
protected function parseContentValue(string $contents, string $path, $value) : string {
8590
$result = $contents;
8691
$items = explode('.', $path);
8792
$key = array_pop($items);
@@ -105,8 +110,8 @@ protected function parseContentValue(string $contents, string $path, $value): st
105110
return $result;
106111
}
107112

108-
protected function writeValueToPhp($value): string
109-
{
113+
protected function writeValueToPhp($value) : string {
114+
110115
if (is_string($value) && strpos($value, "'") === false) {
111116
$replaceValue = "'" . $value . "'";
112117
} elseif (is_string($value) && strpos($value, '"') === false) {
@@ -126,8 +131,7 @@ protected function writeValueToPhp($value): string
126131
return $replaceValue;
127132
}
128133

129-
protected function writeArrayToPhp(array $array): array
130-
{
134+
protected function writeArrayToPhp(array $array) : array {
131135
$result = [];
132136

133137
foreach ($array as $value) {
@@ -141,8 +145,7 @@ protected function writeArrayToPhp(array $array): array
141145
return $result;
142146
}
143147

144-
protected function buildStringExpression(string $targetKey, array $arrayItems = [], string $quoteChar = "'"): string
145-
{
148+
protected function buildStringExpression(string $targetKey, array $arrayItems = [], string $quoteChar = "'") : string {
146149
$expression = [];
147150

148151
// Opening expression for array items ($1)
@@ -163,8 +166,7 @@ protected function buildStringExpression(string $targetKey, array $arrayItems =
163166
/**
164167
* Common constants only (true, false, null, integers)
165168
*/
166-
protected function buildConstantExpression(string $targetKey, array $arrayItems = []): string
167-
{
169+
protected function buildConstantExpression(string $targetKey, array $arrayItems = []) : string {
168170
$expression = [];
169171

170172
// Opening expression for array items ($1)
@@ -182,8 +184,7 @@ protected function buildConstantExpression(string $targetKey, array $arrayItems
182184
/**
183185
* Single level arrays only
184186
*/
185-
protected function buildArrayExpression(string $targetKey, array $arrayItems = []): string
186-
{
187+
protected function buildArrayExpression(string $targetKey, array $arrayItems = []) : string {
187188
$expression = [];
188189

189190
// Opening expression for array items ($1)
@@ -198,8 +199,7 @@ protected function buildArrayExpression(string $targetKey, array $arrayItems = [
198199
return '/' . implode('', $expression) . '/';
199200
}
200201

201-
protected function buildArrayOpeningExpression(array $arrayItems): string
202-
{
202+
protected function buildArrayOpeningExpression(array $arrayItems) : string {
203203
if (count($arrayItems)) {
204204
$itemOpen = [];
205205
foreach ($arrayItems as $item) {

0 commit comments

Comments
 (0)