28 foreach ( $braceTypes as [ $open, $close ] ) {
29 $definitionBalance = $this->getBalance( $definition, $open, $close );
30 $translationBalance = $this->getBalance( $translation, $open, $close );
32 if ( $definitionBalance === 0 && $translationBalance !== 0 ) {
33 $balanceIssues[] =
"$open$close: $translationBalance";
38 if ( $balanceIssues ) {
40 [
'PARAMS', $balanceIssues ],
41 [
'COUNT', count( $balanceIssues ) ],
45 $issue =
new ValidationIssue(
'balance',
'brace',
'translate-checks-balance', $params );
46 $issues->add( $issue );
52 private function getBalance(
string $source,
string $str1,
string $str2 ):
int {
53 return substr_count( $source, $str1 ) - substr_count( $source, $str2 );