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

IntType::getNextVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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