for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Laravel Lodash package.
*
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Longman\LaravelLodash\SelfDiagnosis\Checks;
use BeyondCode\SelfDiagnosis\Checks\Check;
class ElasticsearchCanBeAccessed implements Check
{
private $message;
/**
* The name of the check.
* @param array $config
* @return string
public function name(array $config): string
return trans('lodash::checks.elasticsearch_can_be_accessed.name');
}
* Perform the actual verification of this check.
* @return bool
public function check(array $config): bool
try {
/** @var \Longman\LaravelLodash\ElasticSearch\ElasticSearchManagerContract $elasticsearch */
$elasticsearch = app($config['client']);
if (! $elasticsearch->getClient()->ping()) {
$this->message = trans('lodash::checks.elasticsearch_can_be_accessed.message.not_accessible', [
'error' => 'Ping command was failed',
]);
return false;
} catch (\Throwable $e) {
$this->message = $e->getMessage();
return true;
* The error message to display in case the check does not pass.
public function message(array $config): string
return trans('lodash::checks.elasticsearch_can_be_accessed.message.not_accessible', [
'error' => $this->message,