Notification Setup Error

We have detected an error in your notification set-up (Event-ID dab39dc24f564ec7bd4628d1305fd03c). Currently, we cannot inform you about inspection progress. Please check that the user 557058:bca11929-8c2d-43f2-8a82-c5416880d395 still has access to your repository or update the API account.

Commits   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 90
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 14 2
A get() 0 6 1
A approve() 0 6 1
A deleteApproval() 0 6 1
A comments() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the bitbucket-api package.
5
 *
6
 * (c) Alexandru G. <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bitbucket\API\Repositories;
13
14
use Bitbucket\API\Api;
15
use Bitbucket\API\Repositories\Commits\Comments;
16
use Psr\Http\Message\ResponseInterface;
17
18
/**
19
 * @author  Alexandru G.    <[email protected]>
20
 */
21
class Commits extends Api
22
{
23
    /**
24
     * Get a list of commits
25
     *
26
     * @access public
27
     * @param  string           $account The team or individual account owning the repository.
28
     * @param  string           $repo    The repository identifier.
29
     * @param  array            $params  Additional parameters
30
     * @return ResponseInterface
31 2
     */
32
    public function all($account, $repo, array $params = array())
33 2
    {
34
        $endpoint = sprintf('/repositories/%s/%s/commits', $account, $repo);
35 2
36 1
        if (!empty($params['branch'])) {
37 1
            $endpoint .= '/'.$params['branch']; // can also be a tag
38
            unset($params['branch']);
39
        }
40 2
41 2
        return $this->getClient()->setApiVersion('2.0')->get(
42 2
            $endpoint,
43
            $params
44
        );
45
    }
46
47
    /**
48
     * Get an individual commit
49
     *
50
     * @access public
51
     * @param  string           $account  The team or individual account owning the repository.
52
     * @param  string           $repo     The repository identifier.
53
     * @param  string           $revision A SHA1 value for the commit.
54
     * @return ResponseInterface
55 1
     */
56
    public function get($account, $repo, $revision)
57 1
    {
58 1
        return $this->getClient()->setApiVersion('2.0')->get(
59
            sprintf('/repositories/%s/%s/commit/%s', $account, $repo, $revision)
60
        );
61
    }
62
63
    /**
64
     * Approve a commit
65
     *
66
     * @access public
67
     * @param  string           $account  The team or individual account owning the repository.
68
     * @param  string           $repo     The repository identifier.
69
     * @param  string           $revision A SHA1 value for the commit.
70
     * @return ResponseInterface
71 1
     */
72
    public function approve($account, $repo, $revision)
73 1
    {
74 1
        return $this->getClient()->setApiVersion('2.0')->post(
75
            sprintf('/repositories/%s/%s/commit/%s/approve', $account, $repo, $revision)
76
        );
77
    }
78
79
    /**
80
     * Delete a commit approval
81
     *
82
     * NOTE: On success returns `HTTP/1.1 204 NO CONTENT`
83
     *
84
     * @access public
85
     * @param  string           $account  The team or individual account owning the repository.
86
     * @param  string           $repo     The repository identifier.
87
     * @param  string           $revision A SHA1 value for the commit.
88
     * @return ResponseInterface
89 1
     */
90
    public function deleteApproval($account, $repo, $revision)
91 1
    {
92 1
        return $this->getClient()->setApiVersion('2.0')->delete(
93
            sprintf('/repositories/%s/%s/commit/%s/approve', $account, $repo, $revision)
94
        );
95
    }
96
97
    /**
98
     * Get comments
99
     *
100
     * @access public
101
     * @return Commits\Comments
102
     *
103
     * @throws \InvalidArgumentException
104
     * @codeCoverageIgnore
105
     */
106
    public function comments()
107
    {
108
        return $this->api(Comments::class);
109
    }
110
}
111