Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ParamType
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 cases
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21namespace Wikimedia\Message;
22
23/**
24 * The constants used to specify parameter types. The values of the constants
25 * are an unstable implementation detail.
26 *
27 * Unless otherwise noted, these should be used with an instance of ScalarParam.
28 */
29class ParamType {
30    /** A simple text string or another MessageValue, not otherwise formatted. */
31    public const TEXT = 'text';
32
33    /** A number, to be formatted using local digits and separators */
34    public const NUM = 'num';
35
36    /**
37     * A number of seconds, to be formatted as natural language text.
38     * The value will be output exactly.
39     */
40    public const DURATION_LONG = 'duration';
41
42    /**
43     * A number of seconds, to be formatted as natural language text in an abbreviated way.
44     * The output will be rounded to an appropriate magnitude.
45     */
46    public const DURATION_SHORT = 'period';
47
48    /**
49     * An expiry time.
50     *
51     * The input is either a timestamp in one of the formats accepted by the
52     * Wikimedia\Timestamp library, or "infinity" if the thing doesn't expire.
53     *
54     * The output is a date and time in local format, or a string representing
55     * an "infinite" expiry.
56     */
57    public const EXPIRY = 'expiry';
58
59    /**
60     * A date time in one of the formats accepted by the Wikimedia\Timestamp library.
61     *
62     * The output is a date and time in local format.
63     */
64    public const DATETIME = 'datetime';
65
66    /**
67     * A date in one of the formats accepted by the Wikimedia\Timestamp library.
68     *
69     * The output is a date in local format.
70     */
71    public const DATE = 'date';
72
73    /**
74     * A time in one of the formats accepted by the Wikimedia\Timestamp library.
75     *
76     * The output is a time in local format.
77     */
78    public const TIME = 'time';
79
80    /**
81     * User Group
82     * @since MediaWiki 1.38
83     */
84    public const GROUP = 'group';
85
86    /** A number of bytes. The output will be rounded to an appropriate magnitude. */
87    public const SIZE = 'size';
88
89    /** A number of bits per second. The output will be rounded to an appropriate magnitude. */
90    public const BITRATE = 'bitrate';
91
92    /** A list of values. Must be used with ListParam. */
93    public const LIST = 'list';
94
95    /**
96     * A text parameter which is substituted after formatter processing.
97     *
98     * The creator of the parameter and message is responsible for ensuring
99     * that the value will be safe for the intended output format, and
100     * documenting what that intended output format is.
101     */
102    public const RAW = 'raw';
103
104    /**
105     * A text parameter which is substituted after formatter processing.
106     * The output will be escaped as appropriate for the output format so
107     * as to represent plain text rather than any sort of markup.
108     */
109    public const PLAINTEXT = 'plaintext';
110
111    public static function cases(): array {
112        return [
113            self::TEXT,
114            self::NUM,
115            self::DURATION_LONG,
116            self::DURATION_SHORT,
117            self::EXPIRY,
118            self::DATETIME,
119            self::DATE,
120            self::TIME,
121            self::GROUP,
122            self::SIZE,
123            self::BITRATE,
124            self::LIST,
125            self::RAW,
126            self::PLAINTEXT,
127        ];
128    }
129}