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

Bitbucket   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createIssue() 0 12 1
A getRepositorySlug() 0 4 1
A getAccountSlug() 0 4 1
A getIssueTrackerInstance() 0 4 1
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