Completed
Push — master ( 33de91...d9461a )
by Jonathan
01:31
created

DaterangeHandler::expand()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 2
eloc 9
nc 2
nop 1
1
<?php
2
3
namespace Drupal\Driver\Fields\Drupal8;
4
5
/**
6
 * Daterange field handler for Drupal 8.
7
 */
8
class DaterangeHandler extends AbstractHandler {
9
10
  /**
11
   * {@inheritdoc}
12
   */
13
  public function expand($values) {
14
    $return = [];
15
    foreach ($values as $value) {
16
      $start = str_replace(' ', 'T', $value[0]);
17
      $end = str_replace(' ', 'T', $value[1]);
18
      $return[] = [
19
        'value' => $start,
20
        'end_value' => $end,
21
      ];
22
    }
23
    return $return;
24
  }
25
26
}
27