Completed
Push — master ( bd44b4...5fafbf )
by Portey
03:31
created

TimestampType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 8 2
A isValidValue() 0 4 1
1
<?php
2
/*
3
* This file is a part of graphql-youshido project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 11/27/15 1:22 AM
7
*/
8
9
namespace Youshido\GraphQL\Type\Scalar;
10
11
12
class TimestampType extends AbstractScalarType
13
{
14
15
    /**
16
     * @param $value \DateTime
17
     * @return null|string
18
     */
19
    public function serialize($value)
20
    {
21
        if ($value === null) {
22
            return null;
23
        }
24
25
        return $value->getTimestamp();
26
    }
27
28
    public function isValidValue($value)
29
    {
30
        return is_int($value);
31
    }
32
33
}