Debian Codegraph @

lib/3rdParty/composer/nesbot/carbon/src/Carbon/Traits/ToStringFormat.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 /**
6 * This file is part of the Carbon package.
7 *
8 * (c) Brian Nesbitt <[email protected]>
9 *
10 * For the full copyright and license information, please view the LICENSE
11 * file that was distributed with this source code.
12 */
13
14 namespace Carbon\Traits;
15
16 use Carbon\FactoryImmutable;
17 use Closure;
18
19 /**
20 * Trait ToStringFormat.
21 *
22 * Handle global format customization for string cast of the object.
23 */
24 trait ToStringFormat
25 {
26 /**
27 * Reset the format used to the default when type juggling a Carbon instance to a string
28 *
29 * @return void
30 */
31 public static function resetToStringFormat(): void
32 {
33 FactoryImmutable::getDefaultInstance()->resetToStringFormat();
34 }
35
36 /**
37 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
38 * You should rather let Carbon object being cast to string with DEFAULT_TO_STRING_FORMAT, and
39 * use other method or custom format passed to format() method if you need to dump another string
40 * format.
41 *
42 * Set the default format used when type juggling a Carbon instance to a string.
43 *
44 * @param string|Closure|null $format
45 *
46 * @return void
47 */
48 public static function setToStringFormat(string|Closure|null $format): void
49 {
50 FactoryImmutable::getDefaultInstance()->setToStringFormat($format);
51 }
52 }