Completed
Push — master ( 33bd04...d74de6 )
by Maciej
18:50 queued 11s
created

IntType   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 32
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A convertToDatabaseValue() 0 4 2
A convertToPHPValue() 0 4 2
A closureToMongo() 0 4 1
A closureToPHP() 0 4 1
A diff() 0 4 1
A getNextVersion() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB\Types;
6
7
use function max;
8
9
/**
10
 * The Int type.
11
 */
12
class IntType extends Type implements Incrementable, Versionable
13
{
14 322
    public function convertToDatabaseValue($value)
15
    {
16 322
        return $value !== null ? (int) $value : null;
17
    }
18
19 16
    public function convertToPHPValue($value)
20
    {
21 16
        return $value !== null ? (int) $value : null;
22
    }
23
24
    public function closureToMongo() : string
25
    {
26
        return '$return = (int) $value;';
27
    }
28
29 23
    public function closureToPHP() : string
30
    {
31 23
        return '$return = (int) $value;';
32
    }
33
34 7
    public function diff($old, $new)
35
    {
36 7
        return $new - $old;
37
    }
38
39 39
    public function getNextVersion($current)
40
    {
41 39
        return max(1, (int) $current + 1);
42
    }
43
}
44