Skip to content

Commit 1d3df3e

Browse files
committed
add ExceptionHelper
1 parent 00ae67a commit 1d3df3e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/ExceptionHelper.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Utilitte\Php;
4+
5+
use Nette\Utils\Helpers;
6+
7+
final class ExceptionHelper
8+
{
9+
10+
public static function didYouMean(array $posibilities, string $value): string
11+
{
12+
$suggestion = Helpers::getSuggestion($posibilities, $value);
13+
14+
if ($suggestion !== null) {
15+
return '.';
16+
}
17+
18+
return sprintf(', did you mean "%s"?', $suggestion);
19+
}
20+
21+
}

0 commit comments

Comments
 (0)