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.

Completed
Push — master ( 39a550...af7430 )
by Alexandru
08:39 queued 10s
created

Pipelines::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
crap 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 Buzz\Message\MessageInterface;
16
17
/**
18
 * Manage the pipelines of a repository
19
 *
20
 * @author Marco Veenendaal    <[email protected]>
21
 */
22
class Pipelines extends Api
23
{
24
    /**
25
     * Get the information associated with a repository's pipelines
26
     *
27
     * @access public
28
     * @param  string           $account The team or individual account owning the repository.
29
     * @param  string           $repo    The repository identifier.
30
     * @return MessageInterface
31
     */
32 1
    public function all($account, $repo)
33
    {
34 1
        return $this->getClient()->setApiVersion('2.0')->get(
35 1
            sprintf('repositories/%s/%s/pipelines/', $account, $repo)
36 1
        );
37
    }
38
39
    /**
40
     * Creates a pipeline for the specified repository.
41
     *
42
     * @access public
43
     * @param  string           $account The team or individual account owning the repository.
44
     * @param  string           $repo    The repository identifier.
45
     * @param  array|string     $params  Additional parameters as array or JSON string
46
     * @return MessageInterface
47
     */
48 2
    public function create($account, $repo, $params = array())
49
    {
50
        // allow developer to directly specify params as json if (s)he wants.
51 2
        if ('array' !== gettype($params)) {
52 1
            if (empty($params)) {
53
                throw new \InvalidArgumentException('Invalid JSON provided.');
54
            }
55
56 1
            $params = $this->decodeJSON($params);
57 1
        }
58
59 2
        return $this->getClient()->setApiVersion('2.0')->post(
60 2
            sprintf('repositories/%s/%s/pipelines/', $account, $repo),
61 2
            json_encode($params),
62 2
            array('Content-Type' => 'application/json')
63 2
        );
64
    }
65
66
    /**
67
     * Get a specific pipeline
68
     *
69
     * @access public
70
     * @param  string           $account The team or individual account owning the repository.
71
     * @param  string           $repo    The repository identifier.
72
     * @param  string           $uuid    The pipeline's identifier.
73
     * @return MessageInterface
74
     */
75 1
    public function get($account, $repo, $uuid)
76
    {
77 1
        return $this->getClient()->setApiVersion('2.0')->get(
78 1
            sprintf('repositories/%s/%s/pipelines/%s', $account, $repo, $uuid)
79 1
        );
80
    }
81
82
    /**
83
     * Stop a specific pipeline
84
     *
85
     * @access public
86
     * @param  string           $account The team or individual account owning the repository.
87
     * @param  string           $repo    The repository identifier.
88
     * @param  string           $uuid    The pipeline's identifier.
89
     * @return MessageInterface
90
     */
91 1
    public function stopPipeline($account, $repo, $uuid)
92
    {
93 1
        return $this->getClient()->setApiVersion('2.0')->post(
94 1
            sprintf('repositories/%s/%s/pipelines/%s/stopPipeline', $account, $repo, $uuid)
95 1
        );
96
    }
97
98
    /**
99
     * Get steps
100
     *
101
     * @access public
102
     * @return Pipelines\Steps
103
     *
104
     * @throws \InvalidArgumentException
105
     * @codeCoverageIgnore
106
     */
107
    public function steps()
108
    {
109
        return $this->api('Repositories\\Pipelines\\Steps');
110
    }
111
}
112