Test Failed
Push — master ( 7faec7...d45337 )
by Luka
02:25
created

src/Grant/Grant.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 1
    protected static function getPathToOAuthToken(MastodonClient $client)
30
    {
31 1
        return sprintf('%s://%s/oauth/token', $client->getScheme(), $client->getHostname());
32
    }
33
34
    /**
35
     * @return array
36
     */
37 1
    protected static function getFormParams(AuthFactory $factory)
38
    {
39
        return [
40 1
            'client_id'     => $factory->client_id,
41 1
        ];
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    protected static function getFormParamsWithSecret(AuthFactory $factory)
48
    {
49
        return $this->getFormParams($factory) + [
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
50
            'client_secret' => $factory->client_secret,
51
        ];
52
    }
53
}
54