BasePackage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 6 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Drupal\qa;
6
7
/**
8
 * An instantiable Exportable.
9
 */
10
abstract class BasePackage extends Exportable {
11
12
  /**
13
   * The plugin instances.
14
   *
15
   * @var array
16
   */
17
  protected static $instances = [];
18
19
  /**
20
   * Get a new or existing plugin instance.
21
   *
22
   * @return mixed
23
   *   The plugin.
24
   */
25
  public static function getInstance() {
26
    $name = get_called_class();
27
    if (!isset(self::$instances[$name])) {
28
      self::$instances[$name] = new $name();;
29
    }
30
    return self::$instances[$name];
31
  }
32
33
}
34