• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Cecilapp / Cecil / 5045835811

pending completion
5045835811

Pull #1697

github

GitHub
Merge c3e3c7443 into a16355c73
Pull Request #1697: perf: native_function_invocation

321 of 321 new or added lines in 62 files covered. (100.0%)

2784 of 4121 relevant lines covered (67.56%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Command/ShowConfig.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of Cecil.
7
 *
8
 * Copyright (c) Arnaud Ligny <arnaud@ligny.fr>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Cecil\Command;
15

16
use Cecil\Exception\RuntimeException;
17
use Symfony\Component\Console\Input\InputArgument;
18
use Symfony\Component\Console\Input\InputDefinition;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Input\InputOption;
21
use Symfony\Component\Console\Output\OutputInterface;
22

23
/**
24
 * Shows the configuration.
25
 */
26
class ShowConfig extends AbstractCommand
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function configure()
32
    {
33
        $this
×
34
            ->setName('show:config')
×
35
            ->setDescription('Shows the configuration')
×
36
            ->setDefinition(
×
37
                new InputDefinition([
×
38
                    new InputArgument('path', InputArgument::OPTIONAL, 'Use the given path as working directory'),
×
39
                    new InputOption('config', 'c', InputOption::VALUE_REQUIRED, 'Set the path to the config file'),
×
40
                ])
×
41
            )
×
42
            ->setHelp('Shows the website\'s configuration in YAML format');
×
43
    }
44

45
    /**
46
     * {@inheritdoc}
47
     *
48
     * @throws RuntimeException
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        $output->writeln('<info>Configuration:</info>');
×
53

54
        try {
55
            $output->writeln($this->printArray($this->getBuilder()->getConfig()->getAsArray()));
×
56
        } catch (\Exception $e) {
×
57
            throw new RuntimeException(sprintf($e->getMessage()));
×
58
        }
59

60
        return 0;
×
61
    }
62

63
    /**
64
     * Prints an array in console.
65
     */
66
    private function printArray(array $array, int $column = -2): string
67
    {
68
        $output = '';
×
69

70
        $column += 2;
×
71
        foreach ($array as $key => $val) {
×
72
            switch (\gettype($val)) {
×
73
                case 'array':
×
74
                    $output .= str_repeat(' ', $column) . "$key:\n" . $this->printArray($val, $column);
×
75
                    break;
×
76
                case 'boolean':
×
77
                    $output .= str_repeat(' ', $column) . "$key: " . ($val ? 'true' : 'false') . "\n";
×
78
                    break;
×
79
                default:
80
                    $output .= str_repeat(' ', $column) . "$key: $val\n";
×
81
            }
82
        }
83

84
        return $output;
×
85
    }
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc