Completed
Push — 7.x-1.x ( 2f9e3c...1070be )
by Frédéric G.
01:36
created

Overrides   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 1
B checkViewType() 0 20 5
A run() 0 22 3
1
<?php
2
3
namespace Drupal\qa\Plugin\Qa\Control\Views;
4
5
class Overrides extends Views {
6
7
  /**
8
   * {@inheritdoc]
9
   */
10
  public function init() {
11
    $this->package_name = __NAMESPACE__;
12
    $this->title = t('Non-default views');
13
    $this->description = t('Have any views been overridden or only created in the DB ? This is a performance and change management issue.');
14
  }
15
16
  function checkViewType($view) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
17
    $status = $view->type == t('Default') ? 1 : 0;
18
    if (!$status) {
19
      $name = empty($view->human_name) ? $view->name : $view->human_name;
20
      $result = array(
21
          module_exists('views_ui')
22
          ? l($name, "admin/structure/views/view/{$view->name}/edit")
23
          : $name,
24
          $view->type);
25
    }
26
    else {
27
      $result = NULL;
28
    }
29
    $ret = array(
30
      'name'   => $view->name,
31
      'status' => $status,
32
      'result' => $result,
33
    );
34
    return $ret;
35
  }
36
37
  function run() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
38
    $pass = parent::run();
39
    $views = views_get_all_views(TRUE);
40
    foreach ($views as $view) {
41
      $pass->record($this->checkViewType($view));
42
    }
43
    $pass->life->end();
44
45
    // Prepare for theming
46
    $result = array();
47
    // @XXX May be inconsistent with non-BMP strings ?
48
    uksort($pass->result, 'strcasecmp');
49
    foreach ($pass->result as $view_report) {
50
      $result[] = t('!view: @type', array(
51
        '!view' => $view_report[0], // Built safe in self::checkViewPhp
52
        '@type' => $view_report[1],
53
      ));
54
    }
55
    $result = theme('item_list', array('items' => $result));
56
    $pass->result = $result;
57
    return $pass;
58
  }
59
}
60