InvalidPackageReceivedException::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Thruster\Component\PacketHandler\Exception;
4
5
use Exception;
6
7
/**
8
 * Class InvalidPackageReceivedException
9
 *
10
 * @package Thruster\Component\PacketHandler\Exception
11
 * @author  Aurimas Niekis <[email protected]>
12
 */
13
class InvalidPackageReceivedException extends \Exception
14
{
15
    /**
16
     * @inheritDoc
17
     */
18 2
    public function __construct($package)
19
    {
20 2
        if (is_object($package)) {
21 1
            $message = sprintf(
22 1
                'Received object of class "%s" instead of Package',
23
                get_class($package)
24
            );
25
        } else {
26 1
            $message = sprintf(
27 1
                'Received "%s" instead of object of Package',
28
                gettype($package)
29
            );
30
        }
31
32 2
        parent::__construct($message);
33 2
    }
34
35
}
36