wikimedia/mediawiki-extensions-Wikibase

View on GitHub
repo/includes/ChangeOp/ChangedLanguagesCounter.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Wikibase\Repo\ChangeOp;

/**
 * Counts distinct languages of changed parts in {@link ChangeOpResult} tree
 * @license GPL-2.0-or-later
 */
class ChangedLanguagesCounter {

    public const ZERO_EDIT = 0;
    public const SHORTENED_SUMMARY_MAX_EDIT = 50;

    /**
     * @param ChangeOpResult $changeOpResult
     *
     * @return int count of distinct languages of language-bound results that changed the entity
     */
    public function countChangedLanguages( ChangeOpResult $changeOpResult ): int {
        $changedLanguagesCollector = new ChangedLanguagesCollector();
        $uniqueChangedLanguages = $changedLanguagesCollector->collectChangedLanguages( $changeOpResult );

        return count( $uniqueChangedLanguages );
    }

}