Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ZObjectFilterInRange
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 pass
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2/**
3 * WikiLambda ZObject Authorization Filter: Is Running Function
4 *
5 * @file
6 * @ingroup Extensions
7 * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
8 * @license MIT
9 */
10
11namespace MediaWiki\Extension\WikiLambda\Authorization;
12
13use MediaWiki\Extension\WikiLambda\ZObjectContent\ZObjectContent;
14use MediaWiki\Title\Title;
15
16class ZObjectFilterInRange implements ZObjectFilter {
17
18    /**
19     * ZObject filter that checks whether the edited function is within a certain
20     * Zid range. This determines whether the ZObject is built-in or user-contributed.
21     *
22     * @param ZObjectContent $fromContent
23     * @param ZObjectContent $toContent
24     * @param Title $title
25     * @param array $args
26     * @return bool
27     */
28    public static function pass( $fromContent, $toContent, $title, $args = [] ): bool {
29        $fromId = $args[0] === null ? 0 : (int)substr( $args[0], 1 );
30        $toId = $args[1] === null ? PHP_INT_MAX : (int)substr( $args[1], 1 );
31        $currentId = (int)substr( $title->getText(), 1 );
32        return ( $currentId > $fromId ) && ( $currentId < $toId );
33    }
34}