Skip to content

Commit

Permalink
Fixed string substitution for Plural Value Object when casting to string
Browse files Browse the repository at this point in the history
`\Ibexa\Contracts\Core\Repository\Values\Translation\Plural` had an incorrect casting to string implementation which resulted in the effect opposite to the desired one
  • Loading branch information
alongosz committed Jun 27, 2024
1 parent 52beb2f commit ad4c718
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/contracts/Repository/Values/Translation/Plural.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public function __construct($singular, $plural, array $values)
*/
public function __toString()
{
return strtr(current($this->values) == 1 ? $this->plural : $this->singular, $this->values);
$firstValue = !empty($this->values) ? current(array_values($this->values)) : null;

return strtr((int)$firstValue === 1 ? $this->singular : $this->plural, $this->values);
}
}

Expand Down

0 comments on commit ad4c718

Please sign in to comment.