SerializationException::forObject()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 1
nop 2
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
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 Cubiche\Core\Serializer\Exception;
12
13
use RuntimeException;
14
use Exception;
15
16
/**
17
 * SerializationException class.
18
 *
19
 * @author Ivannis Suárez Jerez <[email protected]>
20
 */
21
class SerializationException extends RuntimeException
22
{
23
    /**
24
     * Creates a new exception for an invalid serialization.
25
     *
26
     * @param object         $object
27
     * @param Exception|null $cause
28
     *
29
     * @return SerializationException
30
     */
31
    public static function forObject($object, Exception $cause = null)
32
    {
33
        return new static(sprintf(
34
            'Invalid serialization for %s object',
35
            is_object($object) ? get_class($object) : gettype($object)
36
        ), 0, $cause);
37
    }
38
}
39