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 ( 94dab8...029788 )
by Devin
03:44
created

DFSMEDSeriesNodes::csvcolumns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 11
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 12
rs 9.4285
1
<?php
2
3
/**
4
 * @file
5
 *  Migrations for Series Nodes.
6
 */
7
8
class DFSMEDSeriesNodes extends DemoFrameworkBaseNodesUUID {
9
  public function __construct($arguments) {
10
    parent::__construct($arguments);
11
    $this->description = t('Import nodes.');
12
    $this->map = new MigrateSQLMap($this->machineName,
13
      array(
14
        'uuid' => array(
15
          'type' => 'char',
16
          'length' => 36,
17
          'not null' => FALSE,
18
        ),
19
      ),
20
      MigrateDestinationNode::getKeySchema()
21
    );
22
    $import_path = drupal_get_path('module', 'dfs_med') . '/import/';
23
    // Create a MigrateSource object.
24
    $this->source = new MigrateSourceCSV($import_path . 'dfs_med.nodes.series.csv', $this->csvcolumns(), array('header_rows' => 1));
25
    $this->destination = new MigrateDestinationNode('series');
26
    // Created
27
    $this->addFieldMapping('created', 'created')->defaultValue(strtotime("now"));
28
    // Brand
29
    $this->addFieldMapping('field_brand', 'brand')->sourceMigration('DFSMEDBrandNodes');
30
    // Associated Product
31
    $this->addFieldMapping('field_commerce_product', 'commerce')->sourceMigration('DFSMEDCommerceNodes');
32
    // Year
33
    $this->addfieldmapping('field_year', 'year');
34
    // Splash Image
35
    $this->addFieldMapping('field_splash_image', 'splash');
36
    $this->addFieldMapping('field_splash_image:file_replace')->defaultValue(FILE_EXISTS_REPLACE);
37
    $this->addFieldMapping('field_splash_image:source_dir')->defaultValue($import_path . 'images');
38
    $this->addFieldMapping('field_splash_image:destination_file', 'filename');
39
    // Series Episodes
40
    $this->addFieldMapping('field_series_episodes', 'episodes')->separator(',')->sourceMigration('DFSMEDEpisodeNodes');
41
    // Persona
42
    $this->addFieldMapping('field_persona', 'persona');
43
    // Site Section
44
    $this->addFieldMapping('field_site_section', 'site_section')->defaultValue("Content");
45
  }
46
47
  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...
48
    $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...
49
    $columns[1] = array('title', 'Title');
50
    $columns[2] = array('brand', 'Brand');
51
    $columns[3] = array('commerce', 'Commerce');
52
    $columns[4] = array('year', 'Year');
53
    $columns[5] = array('splash', 'Splash');
54
    $columns[6] = array('body', 'Body');
55
    $columns[7] = array('episodes', 'Episodes');
56
    $columns[8] = array('persona', 'Persona');
57
    return $columns;
58
  }
59
60
}
61
62