GithubCommitStateFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 24
wmc 5
lcom 0
cbo 4
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 0 14 5
1
<?php
2
3
namespace DevBoardLib\GithubCore\Commit\State;
4
5
use Exception;
6
7
/**
8
 * Class GithubCommitStateFactory.
9
 */
10
class GithubCommitStateFactory
11
{
12
    /**
13
     * @param $githubCommitStateTest
14
     *
15
     * @throws Exception
16
     *
17
     * @return GithubCommitErrorState|GithubCommitFailureState|GithubCommitPendingState|GithubCommitSuccessState
18
     */
19
    public static function create($githubCommitStateTest)
20
    {
21
        if ($githubCommitStateTest === 'pending') {
22
            return new GithubCommitPendingState();
23
        } elseif ($githubCommitStateTest === 'success') {
24
            return new GithubCommitSuccessState();
25
        } elseif ($githubCommitStateTest === 'failure') {
26
            return new GithubCommitFailureState();
27
        } elseif ($githubCommitStateTest === 'error') {
28
            return new GithubCommitErrorState();
29
        }
30
31
        throw new Exception($githubCommitStateTest.' is not recognized commit state');
32
    }
33
}
34