| Conditions | 2 |
| Paths | 2 |
| Total Lines | 26 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public static function fromAttemptedDeSerialisation($object) : self |
||
| 12 | { |
||
| 13 | if (! is_object($object)) { |
||
| 14 | throw TypeError::fromNonObject($object); |
||
| 15 | } |
||
| 16 | |||
| 17 | $template = <<<'ERROR' |
||
| 18 | The given object %s#%s is not designed to be deserialised, yet deserialisation was attempted. |
||
| 19 | |||
| 20 | This error is raised because the author of %s didn't design it to be deserialisable, nor can |
||
| 21 | guarantee that it will function correctly after deserialisation, nor can guarantee that all |
||
| 22 | its internal components are deserialisable. |
||
| 23 | |||
| 24 | Please do not use unserialize() to produce %s instances. |
||
| 25 | ERROR; |
||
| 26 | |||
| 27 | $className = get_class($object); |
||
| 28 | |||
| 29 | return new self(sprintf( |
||
| 30 | $template, |
||
| 31 | $className, |
||
| 32 | spl_object_hash($object), |
||
| 33 | $className, |
||
| 34 | $className |
||
| 35 | )); |
||
| 36 | } |
||
| 37 | } |
||
| 38 |