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

DFSMEDImageFiles   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 1
A csvcolumns() 0 4 1
1
<?php
2
3
/**
4
 * @file
5
 *  Migrations for M&E Image Files.
6
 */
7
8
class DFSMEDImageFiles extends Migration {
9
  public function __construct($arguments) {
10
    parent::__construct($arguments);
11
    $this->map = new MigrateSQLMap($this->machineName,
12
      array(
13
        'image' => array(
14
          'type' => 'varchar',
15
          'length' => 255,
16
          'not null' => TRUE,
17
        ),
18
      ),
19
      MigrateDestinationFile::getKeySchema()
20
    );
21
    $this->destination = new MigrateDestinationFile('image');
22
    $import_path = drupal_get_path('module', 'dfs_med') . '/import/';
23
    $this->source = new MigrateSourceCSV($import_path . 'dfs_med.files.image.csv', $this->csvcolumns(), array('header_rows' => 1));
24
    $this->addFieldMapping('value', 'image');
25
    $this->addFieldMapping('file_replace')->defaultValue(FILE_EXISTS_REPLACE);
26
    $this->addFieldMapping('source_dir')->defaultValue($import_path . 'images');
27
    $this->addFieldMapping('destination_file', 'image'); 
28
  }
29
30
  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...
31
    $columns[0] = array('image', 'Image');
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...
32
    return $columns;
33
  }
34
35
}
36
37