Completed
Push — master ( 6fdfa4...756258 )
by Zbigniew
02:26
created

ApiException::calculateExceptionIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * This file is part of the WrikePhpLibrary package.
4
 *
5
 * (c) Zbigniew Ślązak
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Zibios\WrikePhpLibrary\Exception\Api;
12
13
use Exception;
14
15
/**
16
 * General Wrike Api Exception
17
 *
18
 * Thrown when the Client returns an HTTP error that isn't handled by other dedicated exceptions.
19
 */
20
class ApiException extends Exception
21
{
22
    const STATUS_CODE = null;
23
    const STATUS_NAME = null;
24
25
    /**
26
     * ApiException constructor.
27
     *
28
     * @param Exception $e
29
     */
30 39
    public function __construct(\Exception $e)
31
    {
32 39
        parent::__construct($e->getMessage(), $e->getCode(), $e);
33 39
    }
34
35
    /**
36
     * @return string
37
     * @throws \UnderflowException
38
     */
39 29
    public static function getExceptionIdentifier()
40
    {
41 29
        return static::calculateExceptionIdentifier(static::STATUS_CODE, static::STATUS_NAME);
42
    }
43
44
    /**
45
     * @param int $errorStatusCode
46
     * @param string $errorStatusName
47
     *
48
     * @return string
49
     */
50 29
    public static function calculateExceptionIdentifier($errorStatusCode, $errorStatusName)
51
    {
52 29
        return sprintf('%s%s', $errorStatusCode, $errorStatusName);
53
    }
54
}
55