Completed
Pull Request — master (#157)
by
unknown
01:35
created

TimestampDrupal8   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A processValue() 0 8 3
1
<?php
2
namespace Drupal\Driver\Plugin\DriverField;
3
4
use Drupal\Driver\Plugin\DriverFieldPluginDrupal8Base;
5
6
/**
7
 * A driver field plugin for timestamp fields.
8
 *
9
 * @DriverField(
10
 *   id = "timestamp8",
11
 *   version = 8,
12
 *   fieldTypes = {
13
 *     "timestamp",
14
 *     "created",
15
 *     "changed",
16
 *   },
17
 *   weight = -100,
18
 * )
19
 */
20
class TimestampDrupal8 extends DriverFieldPluginDrupal8Base
21
{
22
23
  /**
24
   * {@inheritdoc}
25
   */
26
    protected function processValue($value)
27
    {
28
      $processedValue = $value;
29
      if (!empty($value['value']) && !is_numeric($value['value'])) {
30
        $processedValue['value'] = strtotime($value['value']);
31
      }
32
      return $processedValue;
33
    }
34
}
35