Code Duplication    Length = 21-29 lines in 16 locations

Check/ClassExistsCollection.php 1 location

@@ 10-38 (lines=29) @@
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10
class ClassExistsCollection implements CheckCollectionInterface
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $className = $config['name'];
21
22
            $check = new ClassExists($className);
23
24
            $label = $config['label'] ?? sprintf('Class `%s` exists', $className);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('class_exists_%s', $className)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}
39

Check/DoctrineDbalCollection.php 1 location

@@ 11-33 (lines=23) @@
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
class DoctrineDbalCollection implements CheckCollectionInterface
12
{
13
    private $checks = [];
14
15
    public function __construct(ConnectionRegistry $manager, $connections)
16
    {
17
        foreach ($connections as $connection) {
18
            $connectionName = $connection['name'];
19
20
            $check = new DoctrineDbal($manager, $connectionName);
21
22
            $label = $connection['label'] ?? sprintf('Doctrine DBAL "%s" connection', $connectionName);
23
            $check->setLabel($label);
24
25
            $this->checks[sprintf('doctrine_dbal_%s_connection', $connectionName)] = $check;
26
        }
27
    }
28
29
    public function getChecks()
30
    {
31
        return $this->checks;
32
    }
33
}
34

Check/DoctrineMongoDbCollection.php 1 location

@@ 11-33 (lines=23) @@
8
/**
9
 * @author Hugues Gobet <[email protected]>
10
 */
11
class DoctrineMongoDbCollection implements CheckCollectionInterface
12
{
13
    private $checks = [];
14
15
    public function __construct(ConnectionRegistry $manager, $connections)
16
    {
17
        foreach ($connections as $connection) {
18
            $connectionName = $connection['name'];
19
20
            $check = new DoctrineDbal($manager, $connectionName);
21
22
            $label = $connection['label'] ?? sprintf('Doctrine Mongo Db "%s" connection', $connectionName);
23
            $check->setLabel($label);
24
25
            $this->checks[sprintf('doctrine_mongodb_%s_connection', $connectionName)] = $check;
26
        }
27
    }
28
29
    public function getChecks()
30
    {
31
        return $this->checks;
32
    }
33
}
34

Check/IniFileCollection.php 1 location

@@ 10-38 (lines=29) @@
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10
class IniFileCollection implements CheckCollectionInterface
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $path = $config['path'];
21
22
            $check = new IniFile($path);
23
24
            $label = $config['label'] ?? sprintf('INI file `%s` exists and valid', $path);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('file_ini_%s', $path)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}
39

Check/JsonFileCollection.php 1 location

@@ 10-38 (lines=29) @@
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10
class JsonFileCollection implements CheckCollectionInterface
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $path = $config['path'];
21
22
            $check = new JsonFile($path);
23
24
            $label = $config['label'] ?? sprintf('JSON file `%s` exists and valid', $path);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('file_json_%s', $path)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}
39

Check/MemcacheCollection.php 1 location

@@ 11-31 (lines=21) @@
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
class MemcacheCollection implements CheckCollectionInterface
12
{
13
    private $checks = [];
14
15
    public function __construct(array $configs)
16
    {
17
        foreach ($configs as $name => $config) {
18
            $check = new Memcache($config['host'], $config['port']);
19
20
            $label = $config['label'] ?? sprintf('Memcache "%s"', $name);
21
            $check->setLabel($label);
22
23
            $this->checks[sprintf('memcache_%s', $name)] = $check;
24
        }
25
    }
26
27
    public function getChecks()
28
    {
29
        return $this->checks;
30
    }
31
}
32

Check/MemcachedCollection.php 1 location

@@ 11-31 (lines=21) @@
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
class MemcachedCollection implements CheckCollectionInterface
12
{
13
    private $checks = [];
14
15
    public function __construct(array $configs)
16
    {
17
        foreach ($configs as $name => $config) {
18
            $check = new Memcached($config['host'], $config['port']);
19
20
            $label = $config['label'] ?? sprintf('Memcached "%s"', $name);
21
            $check->setLabel($label);
22
23
            $this->checks[sprintf('memcached_%s', $name)] = $check;
24
        }
25
    }
26
27
    public function getChecks()
28
    {
29
        return $this->checks;
30
    }
31
}
32

Check/PhpExtensionCollection.php 1 location

@@ 10-38 (lines=29) @@
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10
class PhpExtensionCollection implements CheckCollectionInterface
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $extensionName = $config['name'];
21
22
            $check = new PhpExtension($extensionName);
23
24
            $label = $config['label'] ?? sprintf('PHP extension `%s` is loaded', $extensionName);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('php_extension_%s', $extensionName)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}
39

Check/PhpFlagsCollection.php 1 location

@@ 8-31 (lines=24) @@
5
use Laminas\Diagnostics\Check\CheckCollectionInterface;
6
use Laminas\Diagnostics\Check\PhpFlag;
7
8
class PhpFlagsCollection implements CheckCollectionInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    private $checks = [];
14
15
    public function __construct(array $configs)
16
    {
17
        foreach ($configs as $setting => $value) {
18
            $check = new PhpFlag($setting, $value['value']);
19
20
            $label = $value['label'] ?? sprintf('PHP flag "%s"', $setting);
21
            $check->setLabel($label);
22
23
            $this->checks[sprintf('php_flag_%s', $setting)] = $check;
24
        }
25
    }
26
27
    public function getChecks()
28
    {
29
        return $this->checks;
30
    }
31
}
32

Check/PhpVersionCollection.php 1 location

@@ 8-33 (lines=26) @@
5
use Laminas\Diagnostics\Check\CheckCollectionInterface;
6
use Laminas\Diagnostics\Check\PhpVersion;
7
8
class PhpVersionCollection implements CheckCollectionInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    private $checks = [];
14
15
    public function __construct(array $configs)
16
    {
17
        foreach ($configs as $version => $value) {
18
            $comparisonOperator = $value['operator'];
19
20
            $check = new PhpVersion($version, $comparisonOperator);
21
22
            $label = $value['label'] ?? sprintf('PHP version "%s" "%s"', $comparisonOperator, $version);
23
            $check->setLabel($label);
24
25
            $this->checks[sprintf('php_version_%s', $version)] = $check;
26
        }
27
    }
28
29
    public function getChecks()
30
    {
31
        return $this->checks;
32
    }
33
}
34

Check/ProcessRunningCollection.php 1 location

@@ 11-33 (lines=23) @@
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
class ProcessRunningCollection implements CheckCollectionInterface
12
{
13
    private $checks = [];
14
15
    public function __construct(array $configs)
16
    {
17
        foreach ($configs as $config) {
18
            $processName = $config['name'];
19
20
            $check = new ProcessRunning($processName);
21
22
            $label = $config['label'] ?? sprintf('Process "%s" running', $processName);
23
            $check->setLabel($label);
24
25
            $this->checks[sprintf('process_%s_running', $processName)] = $check;
26
        }
27
    }
28
29
    public function getChecks()
30
    {
31
        return $this->checks;
32
    }
33
}
34

Check/ReadableDirectoryCollection.php 1 location

@@ 10-38 (lines=29) @@
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10
class ReadableDirectoryCollection implements CheckCollectionInterface
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $directoryName = $config['path'];
21
22
            $check = new ReadableDirectory($directoryName);
23
24
            $label = $config['label'] ?? sprintf('Directory `%s` is readable', $directoryName);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('readable_directory_%s', $directoryName)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}
39

Check/StreamWrapperExistsCollection.php 1 location

@@ 10-38 (lines=29) @@
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10
class StreamWrapperExistsCollection implements CheckCollectionInterface
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $streamWrapperName = $config['name'];
21
22
            $check = new StreamWrapperExists($streamWrapperName);
23
24
            $label = $config['label'] ?? sprintf('Stream wrapper `%s` exists', $streamWrapperName);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('stream_wrapper_exists_%s', $streamWrapperName)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}
39

Check/WritableDirectoryCollection.php 1 location

@@ 10-38 (lines=29) @@
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10
class WritableDirectoryCollection implements CheckCollectionInterface
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $directoryName = $config['path'];
21
22
            $check = new WritableDirectory($directoryName);
23
24
            $label = $config['label'] ?? sprintf('Directory `%s` is writable', $directoryName);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('writable_directory_%s', $directoryName)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}

Check/XmlFileCollection.php 1 location

@@ 10-38 (lines=29) @@
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10
class XmlFileCollection implements CheckCollectionInterface
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $path = $config['path'];
21
22
            $check = new XmlFile($path);
23
24
            $label = $config['label'] ?? sprintf('XML file `%s` exists and valid', $path);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('file_xml_%s', $path)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}
39

Check/YamlFileCollection.php 1 location

@@ 10-38 (lines=29) @@
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10
class YamlFileCollection implements CheckCollectionInterface
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $path = $config['path'];
21
22
            $check = new YamlFile($path);
23
24
            $label = $config['label'] ?? sprintf('YAML file `%s` exists and valid', $path);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('file_yaml_%s', $path)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}
39