Passed
Push — develop ( 2a2404...fd09c8 )
by Jens
16:45
created

getCurrentVersion()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.032
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Error;
7
8
/**
9
 * Exeption for response with status code 409
10
 * @package Commercetools\Core\Error
11
 * @description
12
 * When trying to update a resource with a version which differs from the version stored at the commercetools
13
 * platform the API will respond with status code 409.
14
 */
15
class ConcurrentModificationException extends ClientErrorException
16
{
17 51
    public function getCurrentVersion()
18
    {
19 51
        $error = $this->getErrorContainer()->getByCode(ConcurrentModificationError::CODE);
20 51
        if ($error instanceof ConcurrentModificationError) {
21 51
            return $error->getCurrentVersion();
22
        }
23
        return null;
24
    }
25
}
26