Code Duplication    Length = 15-17 lines in 4 locations

src/CheckDefinitions/Elasticsearch.php 1 location

@@ 7-23 (lines=17) @@
4
5
use Symfony\Component\Process\Process;
6
7
class Elasticsearch extends CheckDefinition
8
{
9
    public $command = 'curl --silent http://localhost:9200';
10
11
    public function resolve(Process $process)
12
    {
13
        $checkSucceeded = str_contains($process->getOutput(), 'lucene_version');
14
15
        if ($checkSucceeded) {
16
            $this->check->succeed('is running');
17
18
            return;
19
        }
20
21
        $this->check->fail('is not running');
22
    }
23
}
24

src/CheckDefinitions/Memcached.php 1 location

@@ 7-21 (lines=15) @@
4
5
use Symfony\Component\Process\Process;
6
7
class Memcached extends CheckDefinition
8
{
9
    public $command = 'service memcached status';
10
11
    public function resolve(Process $process)
12
    {
13
        if (str_contains($process->getOutput(), 'memcached is running')) {
14
            $this->check->succeed('is running');
15
16
            return;
17
        }
18
19
        $this->check->fail('is not running');
20
    }
21
}
22

src/CheckDefinitions/MySql.php 1 location

@@ 7-21 (lines=15) @@
4
5
use Symfony\Component\Process\Process;
6
7
class MySql extends CheckDefinition
8
{
9
    public $command = 'ps -e | grep mysqld$';
10
11
    public function resolve(Process $process)
12
    {
13
        if (str_contains($process->getOutput(), 'mysql')) {
14
            $this->check->succeed('is running');
15
16
            return;
17
        }
18
19
        $this->check->fail('is not running');
20
    }
21
}
22

src/CheckDefinitions/Redis.php 1 location

@@ 7-21 (lines=15) @@
4
5
use Symfony\Component\Process\Process;
6
7
class Redis extends CheckDefinition
8
{
9
    public $command = 'redis-cli ping';
10
11
    public function resolve(Process $process)
12
    {
13
        if ('PONG' == trim($process->getOutput())) {
14
            $this->check->succeed('is running');
15
16
            return;
17
        }
18
19
        $this->check->fail('is not running');
20
    }
21
}
22