- Added missing `static` declaration to avoid E_STRIC messages
[haanga.git] / lib / Haanga / Extension / Filter / Pluralize.php
blobdf0a43449968ca9db97584bf7a1f2d855dd31803
1 <?php
3 class Haanga_Extension_Filter_Pluralize
5 static function generator($compiler, $args)
7 if (count($args) > 1) {
8 if (!Haanga_AST::is_str($args[1])) {
9 throw new Haanga_Compiler_Exception("pluralize: First parameter must be an string");
11 $parts = explode(",", $args[1]['string']);
12 $singular = "";
13 if (count($parts) == 1) {
14 $plural = $parts[0];
15 } else {
16 $singular = $parts[0];
17 $plural = $parts[1];
19 } else {
20 $singular = "";
21 $plural = "s";
24 return hexpr_cond(hexpr($args[0], '<=', 1), $singular, $plural);