GithubIssueStateFactory::create()   A
last analyzed

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
3
namespace DevBoardLib\GithubCore\Issue\State;
4
5
use Exception;
6
7
/**
8
 * Class GithubIssueStateFactory.
9
 */
10
class GithubIssueStateFactory
11
{
12
    /**
13
     * @param $githubIssueStateTest
14
     *
15
     * @throws Exception
16
     *
17
     * @return GithubIssueClosedState|GithubIssueOpenState
18
     */
19
    public static function create($githubIssueStateTest)
20
    {
21
        if ($githubIssueStateTest === 'open') {
22
            return new GithubIssueOpenState();
23
        } elseif ($githubIssueStateTest === 'closed') {
24
            return new GithubIssueClosedState();
25
        }
26
27
        throw new Exception($githubIssueStateTest.' is not recognized issue state');
28
    }
29
}
30