Completed
Push — master ( dbfa6d...65a5eb )
by Bernhard
16s queued 12s
created

PushServiceFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 28
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getService() 0 17 2
1
<?php
2
3
/**
4
 * \Wicked\Timely\PushServices\PushServiceFactory
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    wick-ed
15
 * @copyright 2019 Bernhard Wick
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/wick-ed/timely
18
 */
19
20
namespace Wicked\Timely\PushServices;
21
22
use Symfony\Component\Console\Output\OutputInterface;
23
use Wicked\Timely\DotEnvConfiguration;
24
use Wicked\Timely\PushServices\Authentication\MacOsPasswordRetrievalStrategy;
25
26
/**
27
 * Push Service factory
28
 *
29
 * @author    wick-ed
30
 * @copyright 2019 Bernhard Wick
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/wick-ed/timely
33
 */
34
class PushServiceFactory
35
{
36
37
    /**
38
     * Get a push service as configured
39
     *
40
     * @return PushServiceInterface
41
     *
42
     * @throws \JiraRestApi\JiraException
43
     */
44
    public static function getService(OutputInterface $output)
45
    {
46
        $configuration = new DotEnvConfiguration();
47
        $pushService = $configuration->getPushService();
48
        switch ($pushService) {
49
            case 'jira':
50
                $passwordRetrievalStrategy = new MacOsPasswordRetrievalStrategy($output, $configuration);
51
                $pushService = new Jira($passwordRetrievalStrategy);
52
                break;
53
54
            default:
55
                throw new \Exception(sprintf('Cannot create push service instance for "%s" configuration value', $pushService));
56
                break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
57
        }
58
59
        return $pushService;
60
    }
61
}
62