Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ZObjectFilterTypeChanged
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 pass
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * WikiLambda ZObject Authorization Filter: Type has changed
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 ZObjectFilterTypeChanged implements ZObjectFilter {
17
18    /**
19     * ZObject filter that checks whether the type of the value has changed.
20     *
21     * @param ZObjectContent $fromContent
22     * @param ZObjectContent $toContent
23     * @param Title $title
24     * @param array $args
25     * @return bool
26     */
27    public static function pass( $fromContent, $toContent, $title, $args = [] ): bool {
28        $oldType = $fromContent->getZType();
29        $newType = $toContent->getZType();
30        return $oldType !== $newType;
31    }
32}