Completed
Push — master ( 5da4b2...7163c3 )
by Miro
04:03 queued 01:19
created

GithubPullRequestStateFactory   A

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