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