diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..95b07cb
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,9 @@
+
+
+ PHPCS configuration file.
+ src
+ */exclude/*
+
+
+
+
diff --git a/src/Console/LaraLensCommand.php b/src/Console/LaraLensCommand.php
index c588a54..bd76f66 100644
--- a/src/Console/LaraLensCommand.php
+++ b/src/Console/LaraLensCommand.php
@@ -10,36 +10,36 @@
class LaraLensCommand extends Command
{
- private const TABLE_STYLES ='default|borderless|compact|symfony-style-guide|box|box-double';
- private const DEFAULT_STYLE='box-double';
+ private const TABLE_STYLES = 'default|borderless|compact|symfony-style-guide|box|box-double';
+ private const DEFAULT_STYLE = 'box-double';
private const DEFAULT_PATH = '';
- protected $styleTable=self::DEFAULT_STYLE;
+ protected $styleTable = self::DEFAULT_STYLE;
protected $signature = 'laralens:diagnostic
{op=overview : What you want to see, overview or allconfigs (overview|allconfigs)}
{--table=users : name of the table, default users}
{--column-sort=created_at : column name used for sorting}
- {--url-path='.self::DEFAULT_PATH.' : default path for checking URL}
+ {--url-path=' . self::DEFAULT_PATH . ' : default path for checking URL}
{--show=*all : show (all|config|runtime|connection|database|migration)}
- {--width-label='.self::DEFAULT_WIDTH.' : width of column for label}
- {--width-value='.self::DEFAULT_WIDTH.' : width of column for value}
- {--style='.self::DEFAULT_STYLE.' : style of the output table ('.self::TABLE_STYLES.')}
+ {--width-label=' . self::DEFAULT_WIDTH . ' : width of column for label}
+ {--width-value=' . self::DEFAULT_WIDTH . ' : width of column for value}
+ {--style=' . self::DEFAULT_STYLE . ' : style of the output table (' . self::TABLE_STYLES . ')}
{--skip-database : skip database check like connection and migration (if your laravel app doesn\'t need Database)}
';
protected $description = 'Show some application configurations.';
- private const DEFAULT_WIDTH=36;
- protected $widthLabel=self::DEFAULT_WIDTH;
- protected $widthValue=self::DEFAULT_WIDTH;
+ private const DEFAULT_WIDTH = 36;
+ protected $widthLabel = self::DEFAULT_WIDTH;
+ protected $widthValue = self::DEFAULT_WIDTH;
protected $urlPath = self::DEFAULT_PATH;
- public const OPTION_SHOW_NONE= 0b0000000;
- public const OPTION_SHOW_CONFIGS= 0b0000001;
- public const OPTION_SHOW_RUNTIMECONFIGS= 0b00000010;
- public const OPTION_SHOW_CONNECTIONS= 0b00000100;
- public const OPTION_SHOW_DATABASE= 0b00001000;
- public const OPTION_SHOW_MIGRATION= 0b00010000;
+ public const OPTION_SHOW_NONE = 0b0000000;
+ public const OPTION_SHOW_CONFIGS = 0b0000001;
+ public const OPTION_SHOW_RUNTIMECONFIGS = 0b00000010;
+ public const OPTION_SHOW_CONNECTIONS = 0b00000100;
+ public const OPTION_SHOW_DATABASE = 0b00001000;
+ public const OPTION_SHOW_MIGRATION = 0b00010000;
public const OPTION_SHOW_ALL = 0b00011111;
private function allConfigs()
@@ -50,9 +50,9 @@ private function allConfigs()
private function formatCell($string, $width)
{
$retVal = "";
- if (strlen($string)> $width) {
+ if (strlen($string) > $width) {
$retVal = Str::limit($string, $width, '');
- } elseif (strlen($string)< $width) {
+ } elseif (strlen($string) < $width) {
$retVal = str_pad($string, $width);
} else {
$retVal = $string;
@@ -60,7 +60,7 @@ private function formatCell($string, $width)
return $retVal;
}
- private function print_output(array $headers, array $rows)
+ private function printOutput(array $headers, array $rows)
{
$rowsTable = [];
$rowsLine = [];
@@ -88,12 +88,12 @@ private function print_output(array $headers, array $rows)
* 'box-double'
*/
$this->table($headers, $rowsTable, $this->styleTable);
- foreach ($rowsLine as $key =>$line) {
+ foreach ($rowsLine as $key => $line) {
$label = Arr::get($line, "label", "");
$value = Arr::get($line, "value", "");
$lineType = Arr::get($row, "lineType", ResultLens::LINE_TYPE_DEFAULT);
if ($label != "") {
- $this->info($label.":");
+ $this->info($label . ":");
}
if ($lineType === ResultLens::LINE_TYPE_ERROR) {
$this->error($value);
@@ -105,23 +105,23 @@ private function print_output(array $headers, array $rows)
}
}
- private function alert_green($string)
+ private function alertGreen($string)
{
$length = Str::length(strip_tags($string)) + 12;
$this->info(str_repeat('*', $length));
- $this->info('* '.$string.' *');
+ $this->info('* ' . $string . ' *');
$this->info(str_repeat('*', $length));
$this->output->newLine();
}
- private function print_checks(array $rows)
+ private function printChecks(array $rows)
{
if (sizeof($rows) == 0) {
- $this->alert_green("CHECK: everything looks good");
+ $this->alertGreen("CHECK: everything looks good");
} else {
$this->alert("CHECK: issues found");
}
- $idx=0;
+ $idx = 0;
foreach ($rows as $key => $row) {
$label = Arr::get($row, "label", "");
$value = Arr::get($row, "value", "");
@@ -130,7 +130,7 @@ private function print_checks(array $rows)
if ($label != "" & ($lineType === ResultLens::LINE_TYPE_ERROR | ResultLens::isMessageLine($lineType))) {
$idx++;
$this->warn("--- " . $idx . " ------------------");
- $this->warn("*** ". $label);
+ $this->warn("*** " . $label);
}
if ($lineType === ResultLens::LINE_TYPE_ERROR) {
$this->error($value);
@@ -144,30 +144,30 @@ private function print_checks(array $rows)
}
}
- private function overview($checkTable = "users", $columnSorting = "created_at", $show= self::OPTION_SHOW_ALL)
+ private function overview($checkTable = "users", $columnSorting = "created_at", $show = self::OPTION_SHOW_ALL)
{
$ll = new LaraLens();
if ($show & self::OPTION_SHOW_CONFIGS) {
$output = $ll->getConfigs();
- $this->print_output(["Config key via config()", "Values"], $output->toArray());
+ $this->printOutput(["Config key via config()", "Values"], $output->toArray());
}
if ($show & self::OPTION_SHOW_RUNTIMECONFIGS) {
$output = $ll->getRuntimeConfigs();
- $this->print_output(["Runtime Configs", "Values"], $output->toArray());
+ $this->printOutput(["Runtime Configs", "Values"], $output->toArray());
$output = $ll->checkServerRequirements();
- $this->print_output(["Laravel Requirements", "Values"], $output->toArray());
+ $this->printOutput(["Laravel Requirements", "Values"], $output->toArray());
}
if ($show & self::OPTION_SHOW_RUNTIMECONFIGS) {
$output = $ll->checkFiles();
- $this->print_output(["Check files", "Values"], $output->toArray());
+ $this->printOutput(["Check files", "Values"], $output->toArray());
}
if ($show & self::OPTION_SHOW_CONNECTIONS) {
$output = $ll->getConnections($this->urlPath);
- $this->print_output(["Connections", "Values"], $output->toArray());
+ $this->printOutput(["Connections", "Values"], $output->toArray());
}
if ($show & self::OPTION_SHOW_DATABASE) {
$output = $ll->getDatabase($checkTable, $columnSorting);
- $this->print_output(["Database", "Values"], $output->toArray());
+ $this->printOutput(["Database", "Values"], $output->toArray());
}
if ($show & self::OPTION_SHOW_MIGRATION) {
try {
@@ -183,10 +183,10 @@ private function overview($checkTable = "users", $columnSorting = "created_at",
$e->getMessage(),
"Check the Database configuration"
);
- $this->print_output(["Migration" , "result"], $r->toArray());
+ $this->printOutput(["Migration" , "result"], $r->toArray());
}
}
- $this->print_checks($ll->checksBag->toArray());
+ $this->printChecks($ll->checksBag->toArray());
}
@@ -201,10 +201,10 @@ public function handle()
$this->styleTable = self::DEFAULT_STYLE;
}
$columnSorting = $this->option("column-sort");
- $showOptions= $this->option("show");
+ $showOptions = $this->option("show");
if (is_array($showOptions)) {
- if (count($showOptions) >0) {
+ if (count($showOptions) > 0) {
$show = self::OPTION_SHOW_NONE;
if (in_array("all", $showOptions)) {
$show = self::OPTION_SHOW_ALL;
@@ -219,13 +219,12 @@ public function handle()
$show = (in_array("connection", $showOptions)) ? $show | self::OPTION_SHOW_CONNECTIONS : $show ;
$show = (in_array("database", $showOptions)) ? $show | self::OPTION_SHOW_DATABASE : $show ;
$show = (in_array("migration", $showOptions)) ? $show | self::OPTION_SHOW_MIGRATION : $show ;
-
}
}
}
- $this->widthLabel= $this->option("width-label");
- $this->widthValue= $this->option("width-value");
+ $this->widthLabel = $this->option("width-label");
+ $this->widthValue = $this->option("width-value");
$this->urlPath = $this->option("url-path");
if (is_null($this->urlPath)) {
@@ -233,16 +232,16 @@ public function handle()
}
switch ($op) {
- case 'overview':
- $this->overview($checkTable, $columnSorting, $show);
- break;
- case 'allconfigs':
- $this->allConfigs();
- break;
-
- default:
- $this->info("What you mean? try with 'php artisan laralens:diagnostic --help'");
- break;
+ case 'overview':
+ $this->overview($checkTable, $columnSorting, $show);
+ break;
+ case 'allconfigs':
+ $this->allConfigs();
+ break;
+
+ default:
+ $this->info("What you mean? try with 'php artisan laralens:diagnostic --help'");
+ break;
}
}
}
diff --git a/src/LaraLensServiceProvider.php b/src/LaraLensServiceProvider.php
index 8847cf3..e80e0b3 100755
--- a/src/LaraLensServiceProvider.php
+++ b/src/LaraLensServiceProvider.php
@@ -4,7 +4,6 @@
use HiFolks\LaraLens\Console\LaraLensCommand;
use Illuminate\Support\ServiceProvider;
-
use HiFolks\LaraLens\Lens\LaraLens;
class LaraLensServiceProvider extends ServiceProvider
@@ -25,8 +24,9 @@ public function boot()
if ($this->app->runningInConsole()) {
$this->publishes(
[
- __DIR__.'/../config/config.php' => config_path('lara-lens.php'),
- ], 'config'
+ __DIR__ . '/../config/config.php' => config_path('lara-lens.php'),
+ ],
+ 'config'
);
// Publishing the views.
@@ -59,12 +59,13 @@ public function boot()
public function register()
{
// Automatically apply the package configuration
- $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'lara-lens');
+ $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'lara-lens');
// Register the main class to use with the facade
$this->app->singleton(
- 'lara-lens', function () {
- return new LaraLens;
+ 'lara-lens',
+ function () {
+ return new LaraLens();
}
);
}
diff --git a/src/Lens/LaraHttp.php b/src/Lens/LaraHttp.php
index b7aa8f9..a0fd1a1 100644
--- a/src/Lens/LaraHttp.php
+++ b/src/Lens/LaraHttp.php
@@ -1,6 +1,5 @@
response->getStatusCode()>= 400);
+ return ($this->response->getStatusCode() >= 400);
}
}
diff --git a/src/Lens/Traits/ConfigLens.php b/src/Lens/Traits/ConfigLens.php
index 133624b..8620fab 100644
--- a/src/Lens/Traits/ConfigLens.php
+++ b/src/Lens/Traits/ConfigLens.php
@@ -1,4 +1,5 @@
$value) {
$results->add(
- ".env ".$value,
+ ".env " . $value,
env($value)
);
}
@@ -32,9 +33,9 @@ public function getConfigsDatabase(ResultLens $results = null)
if (is_null($results)) {
$results = new ResultLens();
}
- $configKeys=[
+ $configKeys = [
"database.default",
- "database.connections.".config("database.default").".driver",
+ "database.connections." . config("database.default") . ".driver",
"database.connections." . config("database.default") . ".url",
"database.connections." . config("database.default") . ".host",
"database.connections." . config("database.default") . ".port",
@@ -43,7 +44,7 @@ public function getConfigsDatabase(ResultLens $results = null)
];
foreach ($configKeys as $key => $value) {
$results->add(
- "".$value,
+ "" . $value,
config($value)
);
}
@@ -57,7 +58,7 @@ public function getConfigs()
"Running diagnostic",
date('Y-m-d H:i:s')
);
- $configKeys=[
+ $configKeys = [
"app.timezone",
"app.locale",
"app.name",
@@ -65,7 +66,7 @@ public function getConfigs()
];
foreach ($configKeys as $key => $value) {
$results->add(
- "".$value,
+ "" . $value,
config($value)
);
}
diff --git a/src/Lens/Traits/DatabaseLens.php b/src/Lens/Traits/DatabaseLens.php
index 221b10d..294465b 100644
--- a/src/Lens/Traits/DatabaseLens.php
+++ b/src/Lens/Traits/DatabaseLens.php
@@ -6,7 +6,6 @@
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
-
use HiFolks\LaraLens\ResultLens;
trait DatabaseLens
@@ -49,7 +48,7 @@ public function dbConnection()
$dbconnection = false;
$this->checksBag->addErrorAndHint(
"Error Database connection",
- "- ".$e->getCode()." - ". $e->getMessage(),
+ "- " . $e->getCode() . " - " . $e->getMessage(),
"Check out your .env file for these parameters: DB_HOST, DB_DATABASE, DB_USERNAME, DB_PASSWORD"
);
}
@@ -58,27 +57,27 @@ public function dbConnection()
public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, ResultLens $results, $checkTable, $columnSorting)
{
- $connectionName= $dbconnection->getName();
+ $connectionName = $dbconnection->getName();
$results->add(
"Connection name",
$connectionName
);
- $grammar= $dbconnection->getQueryGrammar();
+ $grammar = $dbconnection->getQueryGrammar();
$results->add(
"Query Grammar",
Str::afterLast(get_class($grammar), '\\')
);
- $driverName= $dbconnection->getDriverName();
+ $driverName = $dbconnection->getDriverName();
$results->add(
"Driver name",
$driverName
);
- $databaseName= $dbconnection->getDatabaseName();
+ $databaseName = $dbconnection->getDatabaseName();
$results->add(
"Database name",
$databaseName
);
- $tablePrefix= $dbconnection->getTablePrefix();
+ $tablePrefix = $dbconnection->getTablePrefix();
$results->add(
"Table prefix",
$tablePrefix
@@ -101,7 +100,7 @@ public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, Re
if ($driverName === "mongodb") {
$this->checksBag->addInfoAndHint(
"Connection and PDO driver",
- "It is ok! Because you are using ".$driverName. ", and it doesn't support PDO driver.",
+ "It is ok! Because you are using " . $driverName . ", and it doesn't support PDO driver.",
""
);
} else {
@@ -132,41 +131,41 @@ public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, Re
}
- $connectionType= $dbconnection->getPDO()->getAttribute(\PDO::ATTR_DRIVER_NAME);
+ $connectionType = $dbconnection->getPDO()->getAttribute(\PDO::ATTR_DRIVER_NAME);
$results->add(
"Database connection type",
$connectionType
);
- $stringTables="";
+ $stringTables = "";
switch ($connectionType) {
- case 'mysql':
- $stringTables= $this->getTablesListMysql();
- break;
- case 'sqlite':
- $stringTables = $this->getTablesListSqlite();
- break;
-
- default:
- $stringTables = "<>";
- break;
+ case 'mysql':
+ $stringTables = $this->getTablesListMysql();
+ break;
+ case 'sqlite':
+ $stringTables = $this->getTablesListSqlite();
+ break;
+
+ default:
+ $stringTables = "<>";
+ break;
}
$results->add(
"Tables",
$stringTables
);
- $checkountMessage= "";
+ $checkountMessage = "";
try {
$checkcount = DB::table($checkTable)
->select(DB::raw('*'))
->count();
} catch (\Exception $e) {
$checkcount = 0;
- $checkountMessage= " - error with ".$checkTable." table";
+ $checkountMessage = " - error with " . $checkTable . " table";
$results->addErrorAndHint(
"Table Error",
- "Failed query, table <".$checkTable."> ",
- "Make sure that table <".$checkTable."> exists, available tables : ".(($stringTables == "") ? "Not tables found": $stringTables)
+ "Failed query, table <" . $checkTable . "> ",
+ "Make sure that table <" . $checkTable . "> exists, available tables : " . (($stringTables == "") ? "Not tables found" : $stringTables)
);
}
@@ -188,15 +187,15 @@ public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, Re
} catch (QueryException $e) {
$results->addErrorAndHint(
"Table Error",
- "Failed query, table <".$checkTable."> column <".$columnSorting.">",
- "Make sure that table <".$checkTable."> column <".$columnSorting."> exists"
+ "Failed query, table <" . $checkTable . "> column <" . $columnSorting . ">",
+ "Make sure that table <" . $checkTable . "> column <" . $columnSorting . "> exists"
);
}
}
}
}
- public function getDatabase($checkTable="users", $columnSorting = "created_at")
+ public function getDatabase($checkTable = "users", $columnSorting = "created_at")
{
$results = new ResultLens();
diff --git a/src/Lens/Traits/FilesystemLens.php b/src/Lens/Traits/FilesystemLens.php
index ba03f22..3a17f51 100644
--- a/src/Lens/Traits/FilesystemLens.php
+++ b/src/Lens/Traits/FilesystemLens.php
@@ -1,10 +1,10 @@
checksBag->addWarningAndHint(
"List Languages directory",
"No languages found in " . App::langPath(),
- "If your app needs translations, please fill ". App::langPath()
+ "If your app needs translations, please fill " . App::langPath()
);
}
$results->add(
diff --git a/src/Lens/Traits/HttpConnectionLens.php b/src/Lens/Traits/HttpConnectionLens.php
index b91a765..20aea4b 100644
--- a/src/Lens/Traits/HttpConnectionLens.php
+++ b/src/Lens/Traits/HttpConnectionLens.php
@@ -1,4 +1,5 @@
checksBag->addWarningAndHint(
"Connection HTTP Status",
- "Connection response not 20x, status code: " . $response->status() . " for ".$url,
+ "Connection response not 20x, status code: " . $response->status() . " for " . $url,
$checkUrlHint
);
}
diff --git a/src/Lens/Traits/RuntimeLens.php b/src/Lens/Traits/RuntimeLens.php
index 588fda4..c6d7acc 100644
--- a/src/Lens/Traits/RuntimeLens.php
+++ b/src/Lens/Traits/RuntimeLens.php
@@ -1,4 +1,5 @@
$label) {
- $value =call_user_func("App::".$function);
+ $value = call_user_func("App::" . $function);
if (Str::length($curDir) > 3) {
if (Str::startsWith($value, $curDir)) {
- $value = ".".Str::after($value, $curDir);
+ $value = "." . Str::after($value, $curDir);
}
}
$results->add(
@@ -38,17 +39,17 @@ public function getRuntimeConfigs()
$this->appCaller(
$results,
[
- "version"=> "Laravel Version",
- "getLocale"=>"Locale",
+ "version" => "Laravel Version",
+ "getLocale" => "Locale",
"getNamespace" => "Application namespace",
- "environment"=>"Environment",
- "environmentPath"=>"Environment file directory",
- "environmentFile"=>"Environment file used",
- "environmentFilePath" =>"Full path to the environment file",
- "langPath" =>"Path to the language files",
- "publicPath" =>"Path to the public / web directory",
+ "environment" => "Environment",
+ "environmentPath" => "Environment file directory",
+ "environmentFile" => "Environment file used",
+ "environmentFilePath" => "Full path to the environment file",
+ "langPath" => "Path to the language files",
+ "publicPath" => "Path to the public / web directory",
"storagePath" => "Storage directory",
- "resourcePath" =>"Resources directory",
+ "resourcePath" => "Resources directory",
"getCachedServicesPath" => "Path to the cached services.php",
"getCachedPackagesPath" => "Path to the cached packages.php",
"getCachedConfigPath" => "Path to the configuration cache",
@@ -75,8 +76,8 @@ public function checkServerRequirements()
$laravelVersion = app()->version();
$laravelMajorVersion = Arr::get(explode('.', $laravelVersion), 0, "8");
- $phpExtensionRequirements=[
- "6" =>[
+ $phpExtensionRequirements = [
+ "6" => [
"phpversion" => "7.2.0",
"extensions" => [
"bcmath",
@@ -90,7 +91,7 @@ public function checkServerRequirements()
"xml"
]
],
- "7" =>[
+ "7" => [
"phpversion" => "7.2.5",
"extensions" => [
"bcmath",
@@ -104,7 +105,7 @@ public function checkServerRequirements()
"xml"
]
],
- "8" =>[
+ "8" => [
"phpversion" => "7.3.0",
"extensions" => [
"bcmath",
@@ -125,7 +126,7 @@ public function checkServerRequirements()
$phpVersionRequired = $phpExtensionRequirements[$laravelMajorVersion]["phpversion"];
$results->add(
"Laravel version",
- $laravelVersion . " ( ".$laravelMajorVersion." )"
+ $laravelVersion . " ( " . $laravelMajorVersion . " )"
);
$results->add(
"PHP version",
@@ -157,23 +158,23 @@ public function checkServerRequirements()
}
}
//*** CHECK PHP VERSION
- if (version_compare($phpVersion, $phpVersionRequired) <0) {
+ if (version_compare($phpVersion, $phpVersionRequired) < 0) {
$this->checksBag->addWarningAndHint(
- "PHP (".$phpVersion.") version check",
- "PHP version required: ".$phpVersionRequired.", you have: ".$phpVersion,
- "You need to install PHP version: ".$phpVersionRequired
+ "PHP (" . $phpVersion . ") version check",
+ "PHP version required: " . $phpVersionRequired . ", you have: " . $phpVersion,
+ "You need to install PHP version: " . $phpVersionRequired
);
}
$results->add(
- "PHP (".$phpVersion.") version check",
- "PHP version required: ".$phpVersionRequired.", you have: ".$phpVersion
+ "PHP (" . $phpVersion . ") version check",
+ "PHP version required: " . $phpVersionRequired . ", you have: " . $phpVersion
);
$results->add(
"PHP extensions installed",
implode(",", $modulesOk)
);
- if (count($modulesNotok) >0) {
- $stringHint = "Please install these modules :". PHP_EOL;
+ if (count($modulesNotok) > 0) {
+ $stringHint = "Please install these modules :" . PHP_EOL;
foreach ($modulesNotok as $pko) {
if (key_exists($pko, $helpInstall)) {
$stringHint = $pko . " : " . $helpInstall[$pko] . PHP_EOL;
diff --git a/src/ResultLens.php b/src/ResultLens.php
index 20d4fa1..741a28d 100644
--- a/src/ResultLens.php
+++ b/src/ResultLens.php
@@ -64,7 +64,7 @@ public function add($label, $value, $forceLine = false, $lineType = self::LINE_T
{
$this->result->push(
[
- "label"=> $label,
+ "label" => $label,
"value" => $value,
"isLine" => $forceLine,
"lineType" => $lineType