Passed
Pull Request — 8.x-2.x (#58)
by Frédéric G.
03:34
created

SanityCheckCommand::store()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 4
nop 1
dl 0
loc 14
rs 9.4888
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Drupal\mongodb_watchdog\Command;
6
7
use Drupal\Component\Serialization\Yaml;
8
// @codingStandardsIgnoreLine
9
use Drupal\Console\Annotations\DrupalCommand;
10
use Drupal\Console\Core\Command\ContainerAwareCommand;
11
use Drupal\mongodb_watchdog\Install\Sanitycheck;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
/**
16
 * Class SanityCheckCommand.
17
 *
18
 * @DrupalCommand (
19
 *     extension="mongodb_watchdog",
20
 *     extensionType="module"
21
 * )
22
 */
23 View Code Duplication
class SanityCheckCommand extends ContainerAwareCommand {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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\Core\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;
0 ignored issues
show
Documentation Bug introduced by
It seems like $yaml of type object<Drupal\Component\Serialization\Yaml> is incompatible with the declared type object<Drupal\Core\Serialization\Yaml> of property $yaml.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
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