Completed
Pull Request — master (#20)
by Miro
02:18
created

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