Code Duplication    Length = 39-39 lines in 3 locations

src/Branch/GithubBranchId.php 1 location

@@ 11-49 (lines=39) @@
8
/**
9
 * Class GithubBranchId.
10
 */
11
class GithubBranchId implements Identifier
12
{
13
    /** @var GithubRepoId */
14
    private $githubRepoId;
15
    /** @var string */
16
    private $branchName;
17
18
    /**
19
     * BranchId constructor.
20
     *
21
     * @param GithubRepoId $githubRepoId
22
     * @param              $branchName
23
     */
24
    public function __construct(GithubRepoId $githubRepoId, $branchName)
25
    {
26
        $this->githubRepoId = $githubRepoId;
27
        $this->branchName   = $branchName;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function __toString()
34
    {
35
        return $this->githubRepoId->__toString().'-'.$this->branchName;
36
    }
37
38
    /**
39
     * @param $value
40
     *
41
     * @return GithubBranchId
42
     */
43
    public static function createFromValue($value)
44
    {
45
        list($repoId, $branchName) = explode('-', $value, 2);
46
47
        return new self(new GithubRepoId($repoId), $branchName);
48
    }
49
}
50

src/Commit/GithubCommitId.php 1 location

@@ 11-49 (lines=39) @@
8
/**
9
 * Class GithubCommitId.
10
 */
11
class GithubCommitId implements Identifier
12
{
13
    /** @var GithubRepoId */
14
    private $githubRepoId;
15
    /** @var GithubCommitSha */
16
    private $commitSha;
17
18
    /**
19
     * BranchId constructor.
20
     *
21
     * @param GithubRepoId    $githubRepoId
22
     * @param GithubCommitSha $commitSha
23
     */
24
    public function __construct(GithubRepoId $githubRepoId, GithubCommitSha $commitSha)
25
    {
26
        $this->githubRepoId = $githubRepoId;
27
        $this->commitSha    = $commitSha;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function __toString()
34
    {
35
        return $this->githubRepoId->__toString().'-'.$this->commitSha->__toString();
36
    }
37
38
    /**
39
     * @param $value
40
     *
41
     * @return GithubCommitId
42
     */
43
    public static function createFromValue($value)
44
    {
45
        list($repoId, $commitSha) = explode('-', $value, 2);
46
47
        return new self(new GithubRepoId($repoId), new GithubCommitSha($commitSha));
48
    }
49
}
50

src/Tag/GithubTagId.php 1 location

@@ 11-49 (lines=39) @@
8
/**
9
 * Class GithubTagId.
10
 */
11
class GithubTagId implements Identifier
12
{
13
    /** @var GithubRepoId */
14
    private $githubRepoId;
15
    /** @var string */
16
    private $tagName;
17
18
    /**
19
     * BranchId constructor.
20
     *
21
     * @param GithubRepoId $githubRepoId
22
     * @param              $tagName
23
     */
24
    public function __construct(GithubRepoId $githubRepoId, $tagName)
25
    {
26
        $this->githubRepoId = $githubRepoId;
27
        $this->tagName      = $tagName;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function __toString()
34
    {
35
        return $this->githubRepoId->__toString().'-'.$this->tagName;
36
    }
37
38
    /**
39
     * @param $value
40
     *
41
     * @return GithubTagId
42
     */
43
    public static function createFromValue($value)
44
    {
45
        list($repoId, $tagName) = explode('-', $value, 2);
46
47
        return new self(new GithubRepoId($repoId), $tagName);
48
    }
49
}
50