Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 37 additions & 7 deletions src/Psecio/Iniscan/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,52 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!is_file($path)) {
throw new \Exception('Path is null or not accessible: "'.$path.'"');
}

$this->showIni($output, $path);
}

/**
* Read an INI file and display each of it's configuration
*
* @param OutputInterface $output Output object
* @param string $path The path to the ini file
*
* @return null
*/
protected function showIni(OutputInterface $output, $path)
{
$ini = parse_ini_file($path, true);

$output->writeLn('Current PHP.ini settings from '.$path);
$output->writeLn('##########');

foreach ($ini as $section => $data) {
$output->writeLn('<info>:: '.$section.'</info>');
if (empty($data)) {
$output->writeLn("\t<fg=yellow>No settings</fg=yellow>");
} else {
foreach ($data as $path => $value) {
$output->writeLn("\t".$path.' => '.var_export($value, true));
}
}
$this->showSection($output, $data);
$output->writeLn("-----------------\n");
}

}

/**
* Display a section from the INI file
*
* @param OutputInterface $output Output object
* @param mixed $data The content of the section
*
* @return null
*/
protected function showSection(OutputInterface $output, $data)
{
if (empty($data)) {
$output->writeLn("\t<fg=yellow>No settings</fg=yellow>");
return;
} else if (is_array($data)) {
foreach ($data as $path => $value) {
$output->writeLn("\t".$path.' => '.var_export($value, true));
}
return;
}
$output->writeLn("\t" . var_export($data, true));
}
}