Completed
Pull Request — master (#98)
by
unknown
02:45
created

DatestampHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 25 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 1
dl 6
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A expand() 6 17 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Drupal\Driver\Fields\Drupal7;
4
5
/**
6
 * Datestamp field handler for Drupal 7.
7
 */
8
class DatestampHandler extends AbstractHandler {
9
10
  /**
11
   * {@inheritdoc}
12
   */
13
  public function expand($values) {
14
    $return = array();
15
    if (isset($this->fieldInfo['columns']['value2'])) {
16 View Code Duplication
      foreach ($values as $value) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
        $return[$this->language][] = array(
18
          'value' => strtotime($value[0]),
19
          'value2' => strtotime($value[1]),
20
        );
21
      }
22
    }
23
    else {
24
      foreach ($values as $value) {
25
        $return[$this->language][] = array('value' => strtotime($value));
26
      }
27
    }
28
    return $return;
29
  }
30
31
}
32