GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BridgeFactory   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 57.14 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 5
dl 32
loc 56
ccs 0
cts 23
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getChronosBridge() 16 17 2
A getMarathonBridge() 16 17 2
A getFilesystemBridge() 0 16 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  bthapaliya
6
 * @since:   2017-02-14
7
 */
8
9
10
namespace Chapi\Service\JobRepository;
11
12
use Chapi\Component\Cache\CacheInterface;
13
use Chapi\Component\RemoteClients\ApiClientInterface;
14
use Chapi\Service\JobValidator\JobValidatorServiceInterface;
15
use Psr\Log\LoggerInterface;
16
use Symfony\Component\Filesystem\Filesystem;
17
18
class BridgeFactory
19
{
20 View Code Duplication
    public static function getChronosBridge(
21
        ApiClientInterface $apiClient,
22
        CacheInterface $cache,
23
        JobValidatorServiceInterface $jobEntityValidatorService,
24
        LoggerInterface $logger
25
    ) {
26
        if ($apiClient->ping()) {
27
            return new BridgeChronos(
28
                $apiClient,
29
                $cache,
30
                $jobEntityValidatorService,
31
                $logger
32
            );
33
        }
34
35
        return new DummyBridge($logger);
36
    }
37
38 View Code Duplication
    public static function getMarathonBridge(
39
        ApiClientInterface $apiClient,
40
        CacheInterface $cache,
41
        JobValidatorServiceInterface $jobEntityValidatorService,
42
        LoggerInterface $logger
43
    ) {
44
        if ($apiClient->ping()) {
45
            return new BridgeMarathon(
46
                $apiClient,
47
                $cache,
48
                $jobEntityValidatorService,
49
                $logger
50
            );
51
        }
52
53
        return new DummyBridge($logger);
54
    }
55
56
57
    public static function getFilesystemBridge(
58
        Filesystem $fileSystemService,
59
        CacheInterface $cache,
60
        $repositoryDir,
61
        LoggerInterface $logger
62
    ) {
63
        if (empty($repositoryDir)) {
64
            return new DummyBridge($logger);
65
        }
66
67
        return new BridgeFileSystem(
68
            $fileSystemService,
69
            $cache,
70
            $repositoryDir
71
        );
72
    }
73
}
74