Overrides   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 33
c 0
b 0
f 0
dl 0
loc 54
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 21 3
A checkViewType() 0 20 5
A init() 0 4 1
1
<?php
2
3
namespace Drupal\qa\Views;
4
5
use Drupal\qa\Pass;
6
7
class Overrides extends Views {
8
9
  /**
10
   * {@inheritdoc]
11
   */
12
  public function init() {
13
    $this->package_name = __NAMESPACE__;
14
    $this->title = t('Non-default views');
15
    $this->description = t('Have any views been overridden or only created in the DB ? This is a performance and change management issue.');
16
  }
17
18
  public function checkViewType($view) {
19
    $status = $view->type == t('Default') ? 1 : 0;
20
    if (!$status) {
21
      $name = empty($view->human_name) ? $view->name : $view->human_name;
22
      $result = [
23
          module_exists('views_ui')
0 ignored issues
show
Bug introduced by
The function module_exists was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
          /** @scrutinizer ignore-call */ 
24
          module_exists('views_ui')
Loading history...
24
          ? l($name, "admin/structure/views/view/{$view->name}/edit")
0 ignored issues
show
Bug introduced by
The function l was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
          ? /** @scrutinizer ignore-call */ l($name, "admin/structure/views/view/{$view->name}/edit")
Loading history...
25
          : $name,
26
          $view->type
27
      ];
28
    }
29
    else {
30
      $result = NULL;
31
    }
32
    $ret = [
33
      'name'   => $view->name,
34
      'status' => $status,
35
      'result' => $result,
36
    ];
37
    return $ret;
38
  }
39
40
  public function run(): Pass {
41
    $pass = parent::run();
42
    $views = views_get_all_views(TRUE);
0 ignored issues
show
Bug introduced by
The function views_get_all_views was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
    $views = /** @scrutinizer ignore-call */ views_get_all_views(TRUE);
Loading history...
43
    foreach ($views as $view) {
44
      $pass->record($this->checkViewType($view));
45
    }
46
    $pass->life->end();
47
48
    // Prepare for theming
49
    $result = [];
50
    // @XXX May be inconsistent with non-BMP strings ?
51
    uksort($pass->result, 'strcasecmp');
52
    foreach ($pass->result as $view_report) {
53
      $result[] = t('!view: @type', [
54
        '!view' => $view_report[0], // Built safe in self::checkViewPhp
55
        '@type' => $view_report[1],
56
      ]);
57
    }
58
    $result = theme('item_list', ['items' => $result]);
0 ignored issues
show
Bug introduced by
The function theme was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

58
    $result = /** @scrutinizer ignore-call */ theme('item_list', ['items' => $result]);
Loading history...
59
    $pass->result = $result;
60
    return $pass;
61
  }
62
}
63