Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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