Test Failed
Push — master ( c83fb3...05e696 )
by Luka
02:24
created

Grant::getPathToOAuthToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Baguette\Mastodon\Grant;
4
5
use Baguette\Mastodon\Client as MastodonClient;
6
use Baguette\Mastodon\Service\AuthFactory;
7
use Baguette\Mastodon\Service\Scope;
8
use GuzzleHttp\ClientInterface as GuzzleHttpClient;
9
10
/**
11
 * Mastodon grant request class
12
 *
13
 * @author    USAMI Kenta <[email protected]>
14
 * @copyright 2017 Baguette HQ
15
 * @license   https://www.gnu.org/licenses/gpl-3.0.html GPL-3.0
16
 */
17
abstract class Grant
18
{
19
    /**
20
     * @param Client      $http
21
     * @param AuthFactory $factory
22
     * @param Scope       $scope
23
     */
24
    abstract public function auth(GuzzleHttpClient $http, AuthFactory $factory, Scope $scope);
25
26
    /**
27
     * @return string
28
     */
29
    protected static function getPathToOAuthToken(MastodonClient $client)
30
    {
31
        return sprintf('%s://%s/oauth/token', $client->getScheme(), $client->getHostname());
32
    }
33
34
    /**
35
     * @return array
36
     */
37
    protected static function getFormParams(AuthFactory $factory)
38
    {
39
        return [
40
            'client_id'     => $factory->client_id,
41
            'client_secret' => $factory->client_secret,
42
        ];
43
    }
44
45
}
46