CompactCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 9 1
A execute() 0 8 2
1
<?php
2
3
/**
4
 * @file CompactCommand.php
5
 * @brief This file contains the CompactCommand class.
6
 * @details
7
 * @author Filippo F. Fadda
8
 */
9
10
11
namespace EoC\CLI\Command;
12
13
14
use Symfony\Component\Console\Input\InputOption;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
19
/**
20
 * @brief Starts a compaction for the current selected database.
21
 * @nosubgrouping
22
 */
23
class CompactCommand extends AbstractCommand {
24
25
26
  /**
27
   * @brief Configures the command.
28
   */
29
  protected function configure() {
30
    $this->setName("compact");
31
    $this->setDescription("Starts a compaction for the current selected database or just a set of views");
32
33
    $this->addOption("design-doc",
34
      NULL,
35
      InputOption::VALUE_REQUIRED,
36
      "Name of the design document where are stored the views to compact");
37
  }
38
39
40
  /**
41
   * @brief Executes the command.
42
   */
43
  protected function execute(InputInterface $input, OutputInterface $output) {
44
    $couch = $this->getConnection();
45
46
    if ($designDoc = $input->getOption('design-doc'))
47
      $couch->compactView($this->getDatabase(), $designDoc);
48
    else
49
      $couch->compactDb($this->getDatabase());
50
  }
51
52
}