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

GithubCommitStatusStateFactory::create()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 14
rs 8.8571
cc 5
eloc 10
nc 5
nop 1
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