Completed
Push — master ( adaca1...cbbaf6 )
by Miro
02:00
created

GithubIssueStateFactory::create()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
namespace DevBoardLib\GithubCore\Issue\State;
3
4
use Exception;
5
6
/**
7
 * Class GithubIssueStateFactory.
8
 */
9
class GithubIssueStateFactory
10
{
11
    /**
12
     * @param $githubIssueStateTest
13
     *
14
     * @throws Exception
15
     *
16
     * @return GithubIssueClosedState|GithubIssueOpenState
17
     */
18
    public static function create($githubIssueStateTest)
19
    {
20
        if ($githubIssueStateTest === 'open') {
21
            return new GithubIssueOpenState();
22
        } elseif ($githubIssueStateTest === 'closed') {
23
            return new GithubIssueClosedState();
24
        }
25
26
        throw new Exception($githubIssueStateTest.' is not recognized issue state');
27
    }
28
}
29