Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
27 / 27
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
increment
100.00% covered (success)
100.00%
27 / 27
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 configure
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
1 / 1
1
 execute
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
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 increment extends command
23{
24    /**
25    * {@inheritdoc}
26    */
27    protected function configure()
28    {
29        $this
30            ->setName('config:increment')
31            ->setDescription($this->user->lang('CLI_DESCRIPTION_INCREMENT_CONFIG'))
32            ->addArgument(
33                'key',
34                InputArgument::REQUIRED,
35                $this->user->lang('CLI_CONFIG_OPTION_NAME')
36            )
37            ->addArgument(
38                'increment',
39                InputArgument::REQUIRED,
40                $this->user->lang('CLI_CONFIG_INCREMENT_BY')
41            )
42            ->addOption(
43                'dynamic',
44                'd',
45                InputOption::VALUE_NONE,
46                $this->user->lang('CLI_CONFIG_CANNOT_CACHED')
47            )
48        ;
49    }
50
51    /**
52    * Executes the command config:increment.
53    *
54    * Increments an integer configuration value.
55    *
56    * @param InputInterface  $input  An InputInterface instance
57    * @param OutputInterface $output An OutputInterface instance
58    *
59    * @return int
60    * @see \phpbb\config\config::increment()
61    */
62    protected function execute(InputInterface $input, OutputInterface $output)
63    {
64        $io = new SymfonyStyle($input, $output);
65
66        $key = $input->getArgument('key');
67        $increment = $input->getArgument('increment');
68        $use_cache = !$input->getOption('dynamic');
69
70        $this->config->increment($key, $increment, $use_cache);
71
72        $io->success($this->user->lang('CLI_CONFIG_INCREMENT_SUCCESS', $key));
73
74        return symfony_command::SUCCESS;
75    }
76}