Completed
Push — master ( 5da4b2...7163c3 )
by Miro
04:03 queued 01:19
created

GithubCommitStateFactory   A

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