GithubPullRequestStateFactory::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 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
3
namespace DevBoardLib\GithubCore\PullRequest\State;
4
5
use Exception;
6
7
/**
8
 * Class GithubPullRequestStateFactory.
9
 */
10
class GithubPullRequestStateFactory
11
{
12
    /**
13
     * @param $githubPullRequestStateTest
14
     *
15
     * @throws Exception
16
     *
17
     * @return GithubPullRequestClosedState|GithubPullRequestOpenState
18
     */
19
    public static function create($githubPullRequestStateTest)
20
    {
21
        if ($githubPullRequestStateTest === 'open') {
22
            return new GithubPullRequestOpenState();
23
        } elseif ($githubPullRequestStateTest === 'closed') {
24
            return new GithubPullRequestClosedState();
25
        }
26
27
        throw new Exception($githubPullRequestStateTest.' is not recognized pull request state');
28
    }
29
}
30