Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1431722
MetricSpec.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
MetricSpec.php
View Options
<?php
namespace
Wikimedia\WRStats
;
/**
* Class representation of normalized metric specifications
*
* @internal
*/
class
MetricSpec
{
/** The default (value axis) resolution */
public
const
DEFAULT_RESOLUTION
=
1
;
/** @var string */
public
$type
;
/** @var float|int */
public
$resolution
;
/** @var array<string,SequenceSpec> Sequences in ascending order of expiry */
public
$sequences
;
public
function
__construct
(
array
$spec
)
{
$this
->
type
=
$spec
[
'type'
]
??
'counter'
;
$this
->
resolution
=
$spec
[
'resolution'
]
??
self
::
DEFAULT_RESOLUTION
;
foreach
(
[
'timeStep'
,
'expiry'
]
as
$var
)
{
if
(
isset
(
$spec
[
$var
]
)
)
{
throw
new
WRStatsError
(
"$var must be in the sequences array"
);
}
}
$seqArrays
=
$spec
[
'sequences'
]
??
[];
if
(
!
$seqArrays
)
{
$seqArrays
=
[
[]
];
}
$sequences
=
[];
foreach
(
$seqArrays
as
$i
=>
$seqArray
)
{
if
(
!
is_array
(
$seqArray
)
)
{
throw
new
WRStatsError
(
'sequences must be an array of arrays'
);
}
$seqSpec
=
new
SequenceSpec
(
$seqArray
);
while
(
isset
(
$sequences
[
$seqSpec
->
name
]
)
)
{
$seqSpec
->
name
.=
"s$i"
;
}
$sequences
[
$seqSpec
->
name
]
=
$seqSpec
;
}
uasort
(
$sequences
,
static
function
(
SequenceSpec
$a
,
SequenceSpec
$b
)
{
return
$a
->
hardExpiry
<=>
$b
->
hardExpiry
;
}
);
$this
->
sequences
=
$sequences
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 21:00 (1 d, 20 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d7/95/154c55f7e821190d6bee14ce976c
Default Alt Text
MetricSpec.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment