You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the help of the abstract class [Extension](src/TypeTransformer/Extension.php) you can extend
330
-
the MessagePack protocol with your own types. For example, the code below shows how to create
331
-
an extension that allows you to work transparently with `DateTime` objects:
327
+
Transformers implementing the `Extension` interface are intended to handle [extension types](https://github.com/msgpack/msgpack/blob/master/spec.md#extension-types).
328
+
For example, the code below shows how to create an extension that allows you to work transparently with `DateTime` objects:
332
329
333
330
```php
334
331
use MessagePack\BufferUnpacker;
335
332
use MessagePack\Packer;
336
333
use MessagePack\TypeTransformer\Extension;
337
334
338
-
class DateTimeExtension extends Extension
335
+
class DateTimeExtension implements Extension
339
336
{
340
-
protected function packExt(Packer $packer, $value) : ?string
337
+
private $type;
338
+
339
+
public function __construct(int $type)
340
+
{
341
+
$this->type = $type;
342
+
}
343
+
344
+
public function getType() : int
345
+
{
346
+
return $this->type;
347
+
}
348
+
349
+
public function pack(Packer $packer, $value) : ?string
0 commit comments