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 ( 9e29a0...ca9ee1 )
by Devin
07:35
created

DFSMEDCollectionNodes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 59
rs 10
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 42 1
A csvcolumns() 0 13 1
1
<?php
2
3
/**
4
 * @file
5
 *  Migrations for Collection Nodes.
6
 */
7
8
class DFSMEDCollectionNodes 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.collection.csv', $this->csvcolumns(), array('header_rows' => 1));
25
    $this->destination = new MigrateDestinationNode('episodic_collection');
26
    // Created
27
    $this->addFieldMapping('created', 'created')->defaultValue(strtotime("now"));
28
    // Splash Image
29
    $this->addFieldMapping('field_splash_image', 'splash');
30
    $this->addFieldMapping('field_splash_image:file_replace')->defaultValue(FILE_EXISTS_REPLACE);
31
    $this->addFieldMapping('field_splash_image:source_dir')->defaultValue($import_path . 'images');
32
    $this->addFieldMapping('field_splash_image:destination_file', 'filename');
33
    // Associated Product
34
    $this->addFieldMapping('field_commerce_product', 'commerce')->sourceMigration('DFSMEDCommerceNodes');
35
    // Brand
36
    $this->addFieldMapping('field_brand', 'brand')->sourceMigration('DFSMEDBrandNodes');
37
    // Collected Episodes
38
    $this->addFieldMapping('field_collected', 'episodes')->separator(',')->sourceMigration('DFSMEDEpisodeNodes');
39
    // Featured
40
    $this->addfieldmapping('field_featured', 'featured');
41
    // Featured Image
42
    $this->addFieldMapping('field_featured_image', 'image');
43
    $this->addFieldMapping('field_featured_image:file_replace')->defaultValue(FILE_EXISTS_REPLACE);
44
    $this->addFieldMapping('field_featured_image:source_dir')->defaultValue($import_path . 'images');
45
    $this->addFieldMapping('field_featured_image:destination_file', 'filename');
46
    // Persona
47
    $this->addFieldMapping('field_persona', 'persona');
48
    // Site Section
49
    $this->addFieldMapping('field_site_section', 'site_section')->defaultValue("Content");
50
  }
51
52
  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...
53
    $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...
54
    $columns[1] = array('title', 'Title');
55
    $columns[2] = array('brand', 'Brand');
56
    $columns[3] = array('splash', 'Splash');
57
    $columns[4] = array('commerce', 'Commerce');
58
    $columns[5] = array('body', 'Synopsis');
59
    $columns[6] = array('featured', 'Featured');
60
    $columns[7] = array('image', 'Image');
61
    $columns[8] = array('episodes', 'Episodes');
62
    $columns[9] = array('persona', 'Persona');
63
    return $columns;
64
  }
65
66
}
67
68