Project   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 12
c 1
b 0
f 0
dl 0
loc 67
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A addModule() 0 2 1
A isRequired() 0 2 1
A useCount() 0 9 3
A sort() 0 2 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Drupal\qa\System;
6
7
/**
8
 * Project represents the weakly defined project structure for an extension.
9
 */
10
class Project {
11
  /**
12
   * The list of descriptions for the modules in the project.
13
   *
14
   * @var \Drupal\qa\System\Module[]
15
   */
16
  public $modules = [];
17
18
  /**
19
   * The project name.
20
   *
21
   * @var string
22
   */
23
  public $name;
24
25
  /**
26
   * Project constructor.
27
   *
28
   * @param string $name
29
   *   The project name.
30
   */
31
  public function __construct(string $name) {
32
    $this->name = $name;
33
  }
34
35
  /**
36
   * Add a module description to the project.
37
   *
38
   * @param \Drupal\qa\System\Module $module
39
   *   The description of the module to add.
40
   */
41
  public function addModule(Module $module) {
42
    $this->modules[$module->name] = $module;
43
  }
44
45
  /**
46
   * Sort projects within the module.
47
   */
48
  public function sort() {
49
    ksort($this->modules);
50
  }
51
52
  /**
53
   * Is the project required ?
54
   *
55
   * @return false
56
   *   Is it ?
57
   */
58
  public function isRequired() {
59
    return FALSE;
60
  }
61
62
  /**
63
   * Count the enabled modules in the project.
64
   *
65
   * @return int
66
   *   The count.
67
   */
68
  public function useCount() {
69
    $count = 0;
70
71
    foreach ($this->modules as $module) {
72
      if ($module->isEnabled()) {
73
        $count++;
74
      }
75
    }
76
    return $count;
77
  }
78
79
}
80