Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
get
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 configure
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
1
 execute
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13namespace phpbb\console\command\config;
14
15use Symfony\Component\Console\Command\Command as symfony_command;
16use Symfony\Component\Console\Input\InputArgument;
17use Symfony\Component\Console\Input\InputInterface;
18use Symfony\Component\Console\Input\InputOption;
19use Symfony\Component\Console\Output\OutputInterface;
20use Symfony\Component\Console\Style\SymfonyStyle;
21
22class get extends command
23{
24    /**
25    * {@inheritdoc}
26    */
27    protected function configure()
28    {
29        $this
30            ->setName('config:get')
31            ->setDescription($this->user->lang('CLI_DESCRIPTION_GET_CONFIG'))
32            ->addArgument(
33                'key',
34                InputArgument::REQUIRED,
35                $this->user->lang('CLI_CONFIG_OPTION_NAME')
36            )
37            ->addOption(
38                'no-newline',
39                null,
40                InputOption::VALUE_NONE,
41                $this->user->lang('CLI_CONFIG_PRINT_WITHOUT_NEWLINE')
42            )
43        ;
44    }
45
46    /**
47    * Executes the command config:get.
48    *
49    * Retrieves a configuration value.
50    *
51    * @param InputInterface  $input  An InputInterface instance
52    * @param OutputInterface $output An OutputInterface instance
53    *
54    * @return int
55    * @see \phpbb\config\config::offsetGet()
56    */
57    protected function execute(InputInterface $input, OutputInterface $output)
58    {
59        $io = new SymfonyStyle($input, $output);
60
61        $key = $input->getArgument('key');
62
63        if (isset($this->config[$key]) && $input->getOption('no-newline'))
64        {
65            $output->write($this->config[$key]);
66            return symfony_command::SUCCESS;
67        }
68        else if (isset($this->config[$key]))
69        {
70            $output->writeln($this->config[$key]);
71            return symfony_command::SUCCESS;
72        }
73        else
74        {
75            $io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key));
76            return symfony_command::FAILURE;
77        }
78    }
79}