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

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