Page MenuHomeDevCentral

ConfigValidate.php
No OneTemporary

ConfigValidate.php

<?php
namespace Nasqueron\Notifications\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Filesystem\FilesystemAdapter;
use App;
class ConfigValidate extends Command {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'config:validate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Validates JSON configuration files';
private function getFS () : FilesystemAdapter {
return App::make('filesystem')->disk('local');
}
private function getConfigFiles () : array {
return array_filter(
$this->getFS()->allFiles(),
// Filters *.json
function ($file) : bool {
return substr($file, -5) === ".json";
}
);
}
/**
* Executes the console command.
*/
public function handle() : void {
$files = $this->getConfigFiles();
foreach ($files as $file) {
$content = $this->getFS()->get($file);
if (json_decode($content) === null) {
$this->line("$file — " . json_last_error_msg());
}
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Nov 16, 13:42 (21 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3144422
Default Alt Text
ConfigValidate.php (1 KB)

Event Timeline