Skip to content

Commit a9136c7

Browse files
committed
Create rest benchmark
1 parent 0ae1a5a commit a9136c7

File tree

10 files changed

+15180
-50
lines changed

10 files changed

+15180
-50
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
config.php
21
.idea/
2+
vendor/
3+

Translation/TranslationService.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Php71Benchmark\Translation;
6+
7+
class TranslationService
8+
{
9+
protected static $translations = false;
10+
11+
public static function loadTranslations(): void
12+
{
13+
$locales = ['fr_FR', 'en_GB', 'aa_BB'];
14+
$locale = $locales[rand(0, 2)];
15+
16+
if (file_exists(__DIR__ . '/phpbenchmarks.' . $locale . '.php')) {
17+
static::$translations = require(__DIR__ . '/phpbenchmarks.' . $locale . '.php');
18+
} else {
19+
static::$translations = require(__DIR__ . '/phpbenchmarks.en.php');
20+
}
21+
}
22+
23+
public static function getTranslation(string $key): string
24+
{
25+
return static::$translations[$key] ?? $key;
26+
}
27+
}

0 commit comments

Comments
 (0)