GithubPullRequestStateFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 20
wmc 3
lcom 0
cbo 2
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 3
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