Forks::createFork()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
namespace FlexyProject\GitHub\Receiver\Repositories;
3
4
use FlexyProject\GitHub\AbstractApi;
5
use Symfony\Component\HttpFoundation\Request;
6
7
/**
8
 * The Forks API class provides access to repository's forks.
9
 *
10
 * @link    https://developer.github.com/v3/repos/forks/
11
 * @package FlexyProject\GitHub\Receiver\Repositories
12
 */
13 View Code Duplication
class Forks extends AbstractRepositories
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
16
    /**
17
     * List forks
18
     *
19
     * @link https://developer.github.com/v3/repos/forks/#list-forks
20
     *
21
     * @param string $sort
22
     *
23
     * @return array
24
     */
25
    public function listForks(string $sort = AbstractApi::SORT_NEWEST): array
26
    {
27
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/forks?:arg',
28
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(),
29
            http_build_query(['sort' => $sort])));
30
    }
31
32
    /**
33
     * Create a fork
34
     *
35
     * @link https://developer.github.com/v3/repos/forks/#create-a-fork
36
     *
37
     * @param string $organization
38
     *
39
     * @return array
40
     */
41
    public function createFork(string $organization = ''): array
42
    {
43
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/forks',
44
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()), Request::METHOD_POST,
45
            ['organization' => $organization]);
46
    }
47
}