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

TimestampDrupal8::processValue()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 2
nop 1
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