for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace CodeblogPro\YandexSpeller\Controller;
use Illuminate\Routing\Controller;
use CodeblogPro\YandexSpeller\Application\Services\YandexSpeller\YandexSpellerService;
class YandexSpellerController extends Controller
{
public function index(?string $sourceString = '')
if (!empty($sourceString)) {
try {
$yandexSpellerService = resolve(YandexSpellerService::class);
resolve
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
$yandexSpellerService = /** @scrutinizer ignore-call */ resolve(YandexSpellerService::class);
$yandexSpellerAnswer = $yandexSpellerService->getAnswerByString($sourceString);
} catch (\Throwable $throwable) {
$yandexSpellerAnswer = null;
}
if (empty($yandexSpellerAnswer)) {
$result = [
'status' => 500,
'body' => ['error' => ['message' => 'Internal error. Please, try again later']]
];
} else {
'status' => 200,
'body' => [
'source_string' => $yandexSpellerAnswer->getSourceString(),
'corrected_array' => $yandexSpellerAnswer->getCorrectedArray(),
]
'status' => 400,
'body' => ['error' => ['message' => 'Invalid string']]
return response()->json($result['body'], $result['status']);
response
return /** @scrutinizer ignore-call */ response()->json($result['body'], $result['status']);
public function incorrectMethod()
'status' => 405,
'body' => ['error' => ['message' => 'Method Not Allowed']]