Completed
Push — master ( 42105c...ac8bed )
by Lucas Pires
02:12
created

Bitbucket::getIssueTrackerInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace FlyingLuscas\Laker\Services;
4
5
use FlyingLuscas\Laker\Issue;
6
use FlyingLuscas\Laker\Contracts\ServiceContract;
7
8
class Bitbucket implements ServiceContract
9
{
10
    /**
11
     * Create a new issue on bitbucket.
12
     *
13
     * @param \FlyingLuscas\Laker\Issue $issue
14
     *
15
     * @return \Buzz\Message\Response
16
     */
17
    public function createIssue(Issue $issue)
18
    {
19
        $account = $this->getAccountSlug();
20
        $respository = $this->getRepositorySlug();
21
22
        return $this->getIssueTrackerInstance()->create($account, $respository, [
23
            'title' => $issue->getTitle(),
24
            'content' => $issue->getBody(),
25
            'kind' => 'bug',
26
            'priority' => 'blocker',
27
        ]);
28
    }
29
30
    /**
31
     * Get Bitbucket respository slug.
32
     *
33
     * @return string
34
     */
35
    private function getRepositorySlug()
36
    {
37
        return config('laker.repository_slug');
38
    }
39
40
    /**
41
     * Get Bibucket account slug.
42
     *
43
     * @return string
44
     */
45
    private function getAccountSlug()
46
    {
47
        return config('laker.account_slug');
48
    }
49
50
    /**
51
     * Get issue tracker.
52
     *
53
     * @return \Bitbucket\API\Repositories\Issues
54
     */
55
    private function getIssueTrackerInstance()
56
    {
57
        return app('BitbucketIssuesTracker');
58
    }
59
}
60