MongoDbWatchdogCommands   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A sanityCheck() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Drupal\mongodb_watchdog\Commands;
6
7
use Drupal\mongodb_watchdog\Install\SanityCheck;
8
use Drush\Commands\DrushCommands;
0 ignored issues
show
Bug introduced by
The type Drush\Commands\DrushCommands 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...
9
10
/**
11
 * Drush 9 commands service for the mongodb_watchdog module.
12
 */
13
class MongoDbWatchdogCommands extends DrushCommands {
14
15
  /**
16
   * The mongodb.watchdog.sanity_check service.
17
   *
18
   * @var \Drupal\mongodb_watchdog\Install\SanityCheck
19
   */
20
  protected $sanityCheck;
21
22
  /**
23
   * MongodbWatchdogCommands constructor.
24
   *
25
   * @param \Drupal\mongodb_watchdog\Install\SanityCheck $sanityCheck
26
   *   The mongodb.watchdog.sanity_check service.
27
   */
28
  public function __construct(SanityCheck $sanityCheck) {
29
    $this->sanityCheck = $sanityCheck;
30
  }
31
32
  /**
33
   * Run a sanity check on the contents of the logger database in MongoDB.
34
   *
35
   * @param array<string,mixed> $options
36
   *   A Drush-magic parameter enabling Drush to choose the output format.
37
   *
38
   * @return array{0: int, 1: int, 2: int, 3: int}
39
   *   An array of collection by document count range. A high number of single
40
   *   document collections is a hint of a problem with the application code
41
   *   using the logger subsystem.
42
   *
43
   * @usage mongodb:watchdog:sanitycheck
44
   *   Report on the site of the event collections, per size bucket.
45
   *
46
   * The "unused" $options allows Drush to know the command should support the
47
   * --format option, with the chosen default.
48
   *
49
   * @command mongodb:watchdog:sanitycheck
50
   * @aliases mdbwsc,mowd-sc
51
   */
52
  public function sanityCheck(array $options = ['format' => 'yaml']): array {
53
    return $this->sanityCheck->buildCollectionstats();
54
  }
55
56
}
57