GithubCommitStatusStateFactory::create()   B
last analyzed

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