Passed
Pull Request — 8.x-2.x (#71)
by Frédéric G.
05:37
created

SanityCheckCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 6 1
A execute() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Drupal\mongodb_watchdog\Command;
6
7
use Drupal\Component\Serialization\Yaml;
0 ignored issues
show
Bug introduced by
The type Drupal\Component\Serialization\Yaml was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
// @codingStandardsIgnoreLine
9
use Drupal\Console\Annotations\DrupalCommand;
0 ignored issues
show
Bug introduced by
The type Drupal\Console\Annotations\DrupalCommand was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Drupal\Console\Core\Command\ContainerAwareCommand;
0 ignored issues
show
Bug introduced by
The type Drupal\Console\Core\Command\ContainerAwareCommand was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Drupal\mongodb_watchdog\Install\SanityCheck;
12
use Symfony\Component\Console\Input\InputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Input\InputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Symfony\Component\Console\Output\OutputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Output\OutputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
15
/**
16
 * Class SanityCheckCommand provides the mongodb:watchdog:sanitycheck command.
17
 *
18
 * @DrupalCommand (
19
 *     extension="mongodb_watchdog",
20
 *     extensionType="module"
21
 * )
22
 */
23
class SanityCheckCommand extends ContainerAwareCommand {
24
25
  /**
26
   * The mongodb.watchdog.sanity_check service.
27
   *
28
   * @var \Drupal\mongodb_watchdog\Install\SanityCheck
29
   */
30
  protected $sanityCheck;
31
32
  /**
33
   * The serialisation.yaml service.
34
   *
35
   * @var \Drupal\Component\Serialization\Yaml
36
   */
37
  protected $yaml;
38
39
  /**
40
   * SanityCheckCommand constructor.
41
   *
42
   * @param \Drupal\mongodb_watchdog\Install\Sanitycheck $sanityCheck
43
   *   The mongodb.watchdog.sanity_check service.
44
   * @param \Drupal\Component\Serialization\Yaml $yaml
45
   *   The serialization.yaml service.
46
   */
47
  public function __construct(Sanitycheck $sanityCheck, Yaml $yaml) {
48
    parent::__construct();
49
    $this->sanityCheck = $sanityCheck;
50
    $this->yaml = $yaml;
51
  }
52
53
  /**
54
   * {@inheritdoc}
55
   */
56
  protected function configure(): void {
57
    $this
58
      ->setName('mongodb:watchdog:sanitycheck')
59
      ->setDescription($this->trans('commands.mongodb.watchdog.sanitycheck.description'))
60
      ->setHelp($this->trans('commands.mongodb.watchdog.sanitycheck.help'))
61
      ->setAliases(['mdbwsc', 'mowd-sc']);
62
  }
63
64
  /**
65
   * {@inheritdoc}
66
   */
67
  protected function execute(InputInterface $input, OutputInterface $output): void {
68
    $buckets = $this->sanityCheck->buildCollectionstats();
69
    $this->getIo()->writeln($this->yaml->encode($buckets));
70
  }
71
72
}
73