GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 7.x-1.x ( 34e25a...94dab8 )
by Devin
03:48
created

DFSMEDBrandNodes::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 27
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 37
rs 8.8571
1
<?php
2
3
/**
4
 * @file
5
 *  Migrations for Brand Nodes.
6
 */
7
8
class DFSMEDBrandNodes extends DemoFrameworkBaseNodesUUID {
9
10
  public function __construct($arguments) {
11
    parent::__construct($arguments);
12
    $this->description = t('Import nodes.');
13
    $import_path = drupal_get_path('module', 'dfs_med') . '/import/';
14
    // Create a MigrateSource object.
15
    $this->source = new MigrateSourceCSV($import_path . 'dfs_med.nodes.brand.csv', $this->csvcolumns(), array('header_rows' => 1));
16
    $this->destination = new MigrateDestinationNode('brand');
17
    // Created
18
    $this->addFieldMapping('created', 'created')->defaultValue(strtotime("now"));
19
    // Logo Image
20
    $this->addFieldMapping('field_logo', 'logo');
21
    $this->addFieldMapping('field_logo:file_replace')->defaultValue(FILE_EXISTS_REPLACE);
22
    $this->addFieldMapping('field_logo:source_dir')->defaultValue($import_path . 'images');
23
    $this->addFieldMapping('field_logo:destination_file', 'filename');
24
    // Splash Image
25
    $this->addFieldMapping('field_splash_image', 'splash');
26
    $this->addFieldMapping('field_splash_image:file_replace')->defaultValue(FILE_EXISTS_REPLACE);
27
    $this->addFieldMapping('field_splash_image:source_dir')->defaultValue($import_path . 'images');
28
    $this->addFieldMapping('field_splash_image:destination_file', 'filename');
29
    // Superbrand Link Image
30
    $this->addfieldmapping('field_link_image', 'link_image');
31
    $this->addfieldmapping('field_link_image:file_replace')->defaultvalue(FILE_EXISTS_REPLACE);
32
    $this->addfieldmapping('field_link_image:source_dir')->defaultvalue($import_path . 'images');
33
    $this->addfieldmapping('field_link_image:destination_file', 'filename');
34
    // Superbrand Link Image
35
    $this->addfieldmapping('field_link_image_hover', 'link_image_hover');
36
    $this->addfieldmapping('field_link_image_hover:file_replace')->defaultvalue(FILE_EXISTS_REPLACE);
37
    $this->addfieldmapping('field_link_image_hover:source_dir')->defaultvalue($import_path . 'images');
38
    $this->addfieldmapping('field_link_image_hover:destination_file', 'filename');
39
    // Booleans
40
    $this->addfieldmapping('field_superbrand', 'superbrand');
41
    $this->addfieldmapping('field_greylist', 'greylist');
42
    // Persona
43
    $this->addFieldMapping('field_persona', 'persona');
44
    // Site Section
45
    $this->addFieldMapping('field_site_section', 'site_section')->defaultValue("Content");
46
  }
47
48
  function csvcolumns() {
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...
49
    $columns[0] = array('uuid', 'UUID');
0 ignored issues
show
Coding Style Comprehensibility introduced by
$columns was never initialized. Although not strictly required by PHP, it is generally a good practice to add $columns = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
50
    $columns[1] = array('title', 'Title');
51
    $columns[2] = array('body', 'Body');
52
    $columns[3] = array('logo', 'Logo');
53
    $columns[4] = array('splash', 'Splash');
54
    $columns[5] = array('link_image', 'Link Image');
55
    $columns[6] = array('link_image_hover', 'Link Hover');
56
    $columns[7] = array('superbrand', 'Superbrand');
57
    $columns[8] = array('greylist', 'Greylist');
58
    $columns[9] = array('persona', 'Persona');
59
    return $columns;
60
  }
61
62
}
63
64