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