| Conditions | 8 |
| Paths | 12 |
| Total Lines | 33 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public static function check($message, $locale) |
||
| 31 | { |
||
| 32 | $parts = explode('|', $message); |
||
| 33 | $explicitRules = []; |
||
| 34 | $standardRules = []; |
||
| 35 | foreach ($parts as $part) { |
||
| 36 | $part = trim($part); |
||
| 37 | |||
| 38 | if (preg_match( |
||
| 39 | '/^(?P<interval>' . Interval::getIntervalRegexp() . ')\s*(?P<message> . *?)$/x', |
||
| 40 | $part, |
||
| 41 | $matches |
||
| 42 | )) { |
||
| 43 | $explicitRules[$matches['interval']] = $matches['message']; |
||
| 44 | } elseif (preg_match('/^\w+\:\s*(.*?)$/', $part, $matches)) { |
||
| 45 | $standardRules[] = $matches[1]; |
||
| 46 | } else { |
||
| 47 | $standardRules[] = $part; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | if (count($parts) !== 1 && count($parts) !== count($explicitRules)) { |
||
| 52 | for ($count = 0; $count < 200; $count++) { |
||
| 53 | $position = PluralizationRules::get($count, $locale); |
||
| 54 | |||
| 55 | if (!isset($standardRules[$position])) { |
||
| 56 | return false; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | return true; |
||
| 62 | } |
||
| 63 | } |
||
| 64 |