Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
UserEditCountUpdateHookHandler
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 onUserEditCountUpdate
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3namespace MediaWiki\Extension\CentralAuth\Hooks\Handlers;
4
5use MediaWiki\Extension\CentralAuth\CentralAuthEditCounter;
6use MediaWiki\Extension\CentralAuth\User\CentralAuthUser;
7use MediaWiki\Hook\UserEditCountUpdateHook;
8
9class UserEditCountUpdateHookHandler implements UserEditCountUpdateHook {
10    /** @var CentralAuthEditCounter */
11    private $editCounter;
12
13    public function __construct( CentralAuthEditCounter $editCounter ) {
14        $this->editCounter = $editCounter;
15    }
16
17    /** @inheritDoc */
18    public function onUserEditCountUpdate( $infos ): void {
19        foreach ( $infos as $info ) {
20            $centralUser = CentralAuthUser::getInstanceByName( $info->getUser()->getName() );
21            if ( $centralUser->isAttached() ) {
22                $this->editCounter->increment( $centralUser, $info->getIncrement() );
23            }
24        }
25    }
26}