Conditions | 2 |
Paths | 2 |
Total Lines | 26 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | Please do not serialise %s instances. |
||
19 | ERROR; |
||
20 | |||
21 | /** |
||
22 | * @param object $object |
||
23 | * |
||
24 | * @return NonSerialisableObject |
||
25 | * |
||
26 | * @throws TypeError |
||
27 | */ |
||
28 | public static function fromAttemptedSerialisation($object) : self |
||
29 | { |
||
30 | if (! is_object($object)) { |
||
31 | throw TypeError::fromNonObject($object); |
||
32 | } |
||
33 | |||
34 | $className = get_class($object); |
||
35 | |||
36 | return new self(sprintf( |
||
37 | self::ERROR_TEMPLATE, |
||
38 | $className, |
||
39 | spl_object_hash($object), |
||
40 | $className, |
||
41 | $className |
||
42 | )); |
||
43 | } |
||
44 | } |
||
45 |