Code Duplication    Length = 35-38 lines in 2 locations

lib/GitHub/Receiver/GitData/Blobs.php 1 location

@@ 12-49 (lines=38) @@
9
 * @link    https://developer.github.com/v3/git/blobs/
10
 * @package FlexyProject\GitHub\Receiver\GitData
11
 */
12
class Blobs extends AbstractGitData
13
{
14
15
    /**
16
     * Get a Blob
17
     *
18
     * @link https://developer.github.com/v3/git/blobs/#get-a-blob
19
     *
20
     * @param string $sha
21
     *
22
     * @return array
23
     */
24
    public function getBlob(string $sha): array
25
    {
26
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/git/blobs/:sha',
27
            $this->getGitData()->getOwner(), $this->getGitData()->getRepo(), $sha));
28
    }
29
30
    /**
31
     * Create a Blob
32
     *
33
     * @link https://developer.github.com/v3/git/blobs/#create-a-blob
34
     *
35
     * @param string $content
36
     * @param string $encoding
37
     *
38
     * @return array
39
     */
40
    public function createBlob(string $content, string $encoding = 'utf-8'): array
41
    {
42
        return $this->getApi()->request($this->getApi()
43
                                             ->sprintf('/repos/:owner/:repo/git/blobs', $this->getGitData()->getOwner(),
44
                                                 $this->getGitData()->getRepo()), Request::METHOD_POST, [
45
                'content'  => $content,
46
                'encoding' => $encoding
47
            ]);
48
    }
49
}

lib/GitHub/Receiver/Repositories/Forks.php 1 location

@@ 13-47 (lines=35) @@
10
 * @link    https://developer.github.com/v3/repos/forks/
11
 * @package FlexyProject\GitHub\Receiver\Repositories
12
 */
13
class Forks extends AbstractRepositories
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
}