composer package updates
[openemr.git] / vendor / illuminate / support / Carbon.php
blobdb1bdbef0121d8b5c9eac89399cce218a973e439
1 <?php
3 namespace Illuminate\Support;
5 use JsonSerializable;
6 use Carbon\Carbon as BaseCarbon;
7 use Illuminate\Support\Traits\Macroable;
9 class Carbon extends BaseCarbon implements JsonSerializable
11 use Macroable;
13 /**
14 * The custom Carbon JSON serializer.
16 * @var callable|null
18 protected static $serializer;
20 /**
21 * Prepare the object for JSON serialization.
23 * @return array|string
25 public function jsonSerialize()
27 if (static::$serializer) {
28 return call_user_func(static::$serializer, $this);
31 $carbon = $this;
33 return call_user_func(function () use ($carbon) {
34 return get_object_vars($carbon);
35 });
38 /**
39 * JSON serialize all Carbon instances using the given callback.
41 * @param callable $callback
42 * @return void
44 public static function serializeUsing($callback)
46 static::$serializer = $callback;