Passed
Push — master ( 80cc67...34ea0b )
by Dominic
02:42
created
src/Repositories/CacheTokenRepository.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -10,81 +10,81 @@
 block discarded – undo
10 10
 
11 11
 class CacheTokenRepository implements TokenRepository
12 12
 {
13
-    /**
14
-     * The cache key prefix
15
-     * 
16
-     * @var string
17
-     */
18
-    const PREFIX = 'revolut_';
13
+	/**
14
+	 * The cache key prefix
15
+	 * 
16
+	 * @var string
17
+	 */
18
+	const PREFIX = 'revolut_';
19 19
 
20
-    /**
21
-     * A cache repository
22
-     * 
23
-     * @var \Illuminate\Cache\Repository
24
-     */
25
-    private $cache;
20
+	/**
21
+	 * A cache repository
22
+	 * 
23
+	 * @var \Illuminate\Cache\Repository
24
+	 */
25
+	private $cache;
26 26
 
27
-    /**
28
-     * @param \Illuminate\Contracts\Cache\Factory $cache
29
-     * @param string $driver
30
-     * @return void
31
-     */
32
-    public function __construct(CacheFactory $cache, string $driver = null)
33
-    {
34
-        $this->cache = $cache->store($driver);
35
-    }
27
+	/**
28
+	 * @param \Illuminate\Contracts\Cache\Factory $cache
29
+	 * @param string $driver
30
+	 * @return void
31
+	 */
32
+	public function __construct(CacheFactory $cache, string $driver = null)
33
+	{
34
+		$this->cache = $cache->store($driver);
35
+	}
36 36
 
37
-    public function getAccessToken()
38
-    {
39
-        return $this->cache->get($this->getKey(AccessToken::TYPE));
40
-    }
37
+	public function getAccessToken()
38
+	{
39
+		return $this->cache->get($this->getKey(AccessToken::TYPE));
40
+	}
41 41
 
42
-    public function getRefreshToken()
43
-    {
44
-        return $this->cache->get($this->getKey(RefreshToken::TYPE));
45
-    }
42
+	public function getRefreshToken()
43
+	{
44
+		return $this->cache->get($this->getKey(RefreshToken::TYPE));
45
+	}
46 46
 
47
-    public function createAccessToken(string $value)
48
-    {
49
-        $this->createToken($accessToken = new AccessToken([
50
-            'value' => $value
51
-        ]));
47
+	public function createAccessToken(string $value)
48
+	{
49
+		$this->createToken($accessToken = new AccessToken([
50
+			'value' => $value
51
+		]));
52 52
 
53
-        return $accessToken;
54
-    }
53
+		return $accessToken;
54
+	}
55 55
 
56
-    public function createRefreshToken(string $value)
57
-    {
58
-        $this->createToken($refreshToken = new RefreshToken([
59
-            'value' => $value
60
-        ]));
56
+	public function createRefreshToken(string $value)
57
+	{
58
+		$this->createToken($refreshToken = new RefreshToken([
59
+			'value' => $value
60
+		]));
61 61
 
62
-        return $refreshToken;
63
-    }
62
+		return $refreshToken;
63
+	}
64 64
 
65
-    /**
66
-     * Put the token into the cache
67
-     * 
68
-     * @param \tbclla\Revolut\Interfaces\PersistableToken $token
69
-     * @return void
70
-     */
71
-    private function createToken(PersistableToken $token)
72
-    {
73
-        $this->cache->put(
74
-            $this->getKey($token->getType()),
75
-            $token,
76
-            $token->getExpiration()
77
-        );
78
-    }
65
+	/**
66
+	 * Put the token into the cache
67
+	 * 
68
+	 * @param \tbclla\Revolut\Interfaces\PersistableToken $token
69
+	 * @return void
70
+	 */
71
+	private function createToken(PersistableToken $token)
72
+	{
73
+		$this->cache->put(
74
+			$this->getKey($token->getType()),
75
+			$token,
76
+			$token->getExpiration()
77
+		);
78
+	}
79 79
 
80
-    /**
81
-     * Get the cache key
82
-     *
83
-     * @param string $type
84
-     * @return string
85
-     */
86
-    public function getKey(string $type)
87
-    {
88
-        return self::PREFIX . $type;
89
-    }
80
+	/**
81
+	 * Get the cache key
82
+	 *
83
+	 * @param string $type
84
+	 * @return string
85
+	 */
86
+	public function getKey(string $type)
87
+	{
88
+		return self::PREFIX . $type;
89
+	}
90 90
 }
Please login to merge, or discard this patch.
src/Repositories/DatabaseTokenRepository.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,27 +8,27 @@
 block discarded – undo
8 8
 
9 9
 class DatabaseTokenRepository implements TokenRepository
10 10
 {
11
-    public function getAccessToken()
12
-    {
13
-        return AccessToken::active()->orderBy('id', 'desc')->first();
14
-    }
11
+	public function getAccessToken()
12
+	{
13
+		return AccessToken::active()->orderBy('id', 'desc')->first();
14
+	}
15 15
 
16
-    public function getRefreshToken()
17
-    {
18
-        return RefreshToken::orderBy('id', 'desc')->first();
19
-    }
16
+	public function getRefreshToken()
17
+	{
18
+		return RefreshToken::orderBy('id', 'desc')->first();
19
+	}
20 20
 
21
-    public function createAccessToken(string $value)
22
-    {
23
-        return AccessToken::create([
24
-            'value' => $value
25
-        ]);
26
-    }
21
+	public function createAccessToken(string $value)
22
+	{
23
+		return AccessToken::create([
24
+			'value' => $value
25
+		]);
26
+	}
27 27
 
28
-    public function createRefreshToken(string $value)
29
-    {
30
-        return RefreshToken::create([
31
-            'value' => $value
32
-        ]);
33
-    }
28
+	public function createRefreshToken(string $value)
29
+	{
30
+		return RefreshToken::create([
31
+			'value' => $value
32
+		]);
33
+	}
34 34
 }
Please login to merge, or discard this patch.
src/Auth/AuthorizationCode.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,35 +6,35 @@
 block discarded – undo
6 6
 
7 7
 class AuthorizationCode implements GrantsAccessTokens
8 8
 {
9
-    /**
10
-     * The token value
11
-     * 
12
-     * @var string
13
-     */
14
-    public $value;
9
+	/**
10
+	 * The token value
11
+	 * 
12
+	 * @var string
13
+	 */
14
+	public $value;
15 15
 
16
-    /**
17
-     * Create a new authorization code instance
18
-     * 
19
-     * @param string $value The authorization code supplied by Revolut
20
-     */
21
-    public function __construct(string $value)
22
-    {
23
-        $this->value = $value;
24
-    }
16
+	/**
17
+	 * Create a new authorization code instance
18
+	 * 
19
+	 * @param string $value The authorization code supplied by Revolut
20
+	 */
21
+	public function __construct(string $value)
22
+	{
23
+		$this->value = $value;
24
+	}
25 25
 
26
-    public function getValue()
27
-    {
28
-        return $this->value;
29
-    }
26
+	public function getValue()
27
+	{
28
+		return $this->value;
29
+	}
30 30
 
31
-    public static function getType()
32
-    {
33
-        return 'code';
34
-    }
31
+	public static function getType()
32
+	{
33
+		return 'code';
34
+	}
35 35
 
36
-    public static function getGrantType()
37
-    {
38
-        return 'authorization_code';
39
-    }
36
+	public static function getGrantType()
37
+	{
38
+		return 'authorization_code';
39
+	}
40 40
 }
Please login to merge, or discard this patch.
src/Auth/TokenManager.php 1 patch
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -9,107 +9,107 @@
 block discarded – undo
9 9
 
10 10
 class TokenManager
11 11
 {
12
-    /**
13
-     * The token repository
14
-     *
15
-     * @var \tbclla\Revolut\Interfaces\TokenRepository
16
-     */
17
-    private $tokenRepository;
12
+	/**
13
+	 * The token repository
14
+	 *
15
+	 * @var \tbclla\Revolut\Interfaces\TokenRepository
16
+	 */
17
+	private $tokenRepository;
18 18
 
19
-    /**
20
-     * The access token request
21
-     *
22
-     * @var \tbclla\Revolut\Auth\Requests\AccessTokenRequest
23
-     */
24
-    private $accessTokenRequest;
19
+	/**
20
+	 * The access token request
21
+	 *
22
+	 * @var \tbclla\Revolut\Auth\Requests\AccessTokenRequest
23
+	 */
24
+	private $accessTokenRequest;
25 25
 
26
-    /**
27
-     * Create a token manager
28
-     *
29
-     * @param \tbclla\Revolut\Interfaces\TokenRepository $tokenRepository
30
-     * @param \tbclla\Revolut\Auth\Requests\AccessTokenRequest $accessTokenRequest
31
-     * @return void
32
-     */
33
-    public function __construct(TokenRepository $tokenRepository, AccessTokenRequest $accessTokenRequest)
34
-    {
35
-        $this->tokenRepository = $tokenRepository;
36
-        $this->accessTokenRequest = $accessTokenRequest;
37
-    }
26
+	/**
27
+	 * Create a token manager
28
+	 *
29
+	 * @param \tbclla\Revolut\Interfaces\TokenRepository $tokenRepository
30
+	 * @param \tbclla\Revolut\Auth\Requests\AccessTokenRequest $accessTokenRequest
31
+	 * @return void
32
+	 */
33
+	public function __construct(TokenRepository $tokenRepository, AccessTokenRequest $accessTokenRequest)
34
+	{
35
+		$this->tokenRepository = $tokenRepository;
36
+		$this->accessTokenRequest = $accessTokenRequest;
37
+	}
38 38
 
39
-    /**
40
-     * Get an access token from the repository,
41
-     * or request a new access token
42
-     *
43
-     * @return \tbclla\Revolut\Auth\AccessToken
44
-     */
45
-    public function getAccessToken()
46
-    {
47
-        $accessToken = $this->tokenRepository->getAccessToken();
39
+	/**
40
+	 * Get an access token from the repository,
41
+	 * or request a new access token
42
+	 *
43
+	 * @return \tbclla\Revolut\Auth\AccessToken
44
+	 */
45
+	public function getAccessToken()
46
+	{
47
+		$accessToken = $this->tokenRepository->getAccessToken();
48 48
 
49
-        return $accessToken ?? $this->refreshAccessToken();
50
-    }
49
+		return $accessToken ?? $this->refreshAccessToken();
50
+	}
51 51
 
52
-    /**
53
-     * Get a refresh token from the repository
54
-     *
55
-     * @return \tbclla\Revolut\Auth\RefreshToken|null
56
-     */
57
-    public function getRefreshToken()
58
-    {
59
-        return $this->tokenRepository->getRefreshToken();
60
-    }
52
+	/**
53
+	 * Get a refresh token from the repository
54
+	 *
55
+	 * @return \tbclla\Revolut\Auth\RefreshToken|null
56
+	 */
57
+	public function getRefreshToken()
58
+	{
59
+		return $this->tokenRepository->getRefreshToken();
60
+	}
61 61
 
62
-    /**
63
-     * Store a new access token
64
-     *
65
-     * @param string $value
66
-     * @return \tbclla\Revolut\Auth\AccessToken
67
-     */
68
-    public function createAccessToken(string $value)
69
-    {
70
-        return $this->tokenRepository->createAccessToken($value);
71
-    }
62
+	/**
63
+	 * Store a new access token
64
+	 *
65
+	 * @param string $value
66
+	 * @return \tbclla\Revolut\Auth\AccessToken
67
+	 */
68
+	public function createAccessToken(string $value)
69
+	{
70
+		return $this->tokenRepository->createAccessToken($value);
71
+	}
72 72
 
73
-    /**
74
-     * Store a new refresh token
75
-     *
76
-     * @param string $value
77
-     * @return \tbclla\Revolut\Auth\RefreshToken
78
-     */
79
-    public function createRefreshToken(string $value)
80
-    {
81
-        return $this->tokenRepository->createRefreshToken($value);
82
-    }
73
+	/**
74
+	 * Store a new refresh token
75
+	 *
76
+	 * @param string $value
77
+	 * @return \tbclla\Revolut\Auth\RefreshToken
78
+	 */
79
+	public function createRefreshToken(string $value)
80
+	{
81
+		return $this->tokenRepository->createRefreshToken($value);
82
+	}
83 83
 
84
-    /**
85
-     * Exchange a refresh token for a new access token
86
-     *
87
-     * @return \tbclla\Revolut\Auth\AccessToken
88
-     * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException
89
-     */
90
-    public function refreshAccessToken()
91
-    {
92
-        if (!$refreshToken = $this->getRefreshToken()) {
93
-            throw new AppUnauthorizedException('No refresh token found. Re-authorization required.');
94
-        }
84
+	/**
85
+	 * Exchange a refresh token for a new access token
86
+	 *
87
+	 * @return \tbclla\Revolut\Auth\AccessToken
88
+	 * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException
89
+	 */
90
+	public function refreshAccessToken()
91
+	{
92
+		if (!$refreshToken = $this->getRefreshToken()) {
93
+			throw new AppUnauthorizedException('No refresh token found. Re-authorization required.');
94
+		}
95 95
 
96
-        return $this->requestAccessToken($refreshToken);
97
-    }
96
+		return $this->requestAccessToken($refreshToken);
97
+	}
98 98
 
99
-    /**
100
-     * Request a new access token
101
-     *
102
-     * @param \tbclla\Revolut\Interfaces\GrantsAccessTokens $token
103
-     * @return \tbclla\Revolut\Auth\AccessToken
104
-     */
105
-    public function requestAccessToken(GrantsAccessTokens $token)
106
-    {
107
-        $response = $this->accessTokenRequest->exchange($token);
99
+	/**
100
+	 * Request a new access token
101
+	 *
102
+	 * @param \tbclla\Revolut\Interfaces\GrantsAccessTokens $token
103
+	 * @return \tbclla\Revolut\Auth\AccessToken
104
+	 */
105
+	public function requestAccessToken(GrantsAccessTokens $token)
106
+	{
107
+		$response = $this->accessTokenRequest->exchange($token);
108 108
 
109
-        if (isset($response['refresh_token'])) {
110
-            $this->createRefreshToken($response['refresh_token']);
111
-        }
109
+		if (isset($response['refresh_token'])) {
110
+			$this->createRefreshToken($response['refresh_token']);
111
+		}
112 112
 
113
-        return $this->createAccessToken($response['access_token']);
114
-    }
113
+		return $this->createAccessToken($response['access_token']);
114
+	}
115 115
 }
Please login to merge, or discard this patch.
src/Auth/Requests/AccessTokenRequest.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -9,92 +9,92 @@
 block discarded – undo
9 9
 
10 10
 class AccessTokenRequest
11 11
 {
12
-    /**
13
-     * The authentication endpoint
14
-     * 
15
-     * @var string
16
-     */
17
-    const ENDPOINT = '/auth/token';
12
+	/**
13
+	 * The authentication endpoint
14
+	 * 
15
+	 * @var string
16
+	 */
17
+	const ENDPOINT = '/auth/token';
18 18
 
19
-    /**
20
-     * The client assertion
21
-     *
22
-     * @var \tbclla\Revolut\Auth\ClientAssertion
23
-     */
24
-    private $clientAssertion;
19
+	/**
20
+	 * The client assertion
21
+	 *
22
+	 * @var \tbclla\Revolut\Auth\ClientAssertion
23
+	 */
24
+	private $clientAssertion;
25 25
 
26
-    /**
27
-     * The HTTP client
28
-     *
29
-     * @var \tbclla\Revolut\Interfaces\MakesHttpRequests
30
-     */
31
-    private $httpClient;
26
+	/**
27
+	 * The HTTP client
28
+	 *
29
+	 * @var \tbclla\Revolut\Interfaces\MakesHttpRequests
30
+	 */
31
+	private $httpClient;
32 32
 
33
-    /**
34
-     * Create a new access token request instance
35
-     * 
36
-     * @param \tbclla\Revolut\Auth\ClientAssertion $clientAssertion
37
-     * @param \tbclla\Revolut\Interfaces\MakesHttpRequests $httpClient
38
-     * @return void
39
-     */
40
-    public function __construct(ClientAssertion $clientAssertion, MakesHttpRequests $httpClient)
41
-    {
42
-        $this->clientAssertion = $clientAssertion;
43
-        $this->httpClient = $httpClient;
44
-    }
33
+	/**
34
+	 * Create a new access token request instance
35
+	 * 
36
+	 * @param \tbclla\Revolut\Auth\ClientAssertion $clientAssertion
37
+	 * @param \tbclla\Revolut\Interfaces\MakesHttpRequests $httpClient
38
+	 * @return void
39
+	 */
40
+	public function __construct(ClientAssertion $clientAssertion, MakesHttpRequests $httpClient)
41
+	{
42
+		$this->clientAssertion = $clientAssertion;
43
+		$this->httpClient = $httpClient;
44
+	}
45 45
 
46
-    /**
47
-     * Exchange an authorization code or a refresh token for an access token
48
-     *
49
-     * @param \tbclla\Revolut\Interfaces\GrantsAccessTokens $requestToken
50
-     * @return array
51
-     */
52
-    public function exchange(GrantsAccessTokens $requestToken)
53
-    {
54
-        return $this->httpClient->post($this->uri(), [
55
-            'form_params' => array_merge(
56
-                $this->buildClientParams(),
57
-                $this->buildGrantParams($requestToken)
58
-            )
59
-        ]);
60
-    }
46
+	/**
47
+	 * Exchange an authorization code or a refresh token for an access token
48
+	 *
49
+	 * @param \tbclla\Revolut\Interfaces\GrantsAccessTokens $requestToken
50
+	 * @return array
51
+	 */
52
+	public function exchange(GrantsAccessTokens $requestToken)
53
+	{
54
+		return $this->httpClient->post($this->uri(), [
55
+			'form_params' => array_merge(
56
+				$this->buildClientParams(),
57
+				$this->buildGrantParams($requestToken)
58
+			)
59
+		]);
60
+	}
61 61
 
62
-    /**
63
-     * Get the Uri for the request
64
-     * 
65
-     * @return string
66
-     */
67
-    public static function uri()
68
-    {
69
-        return RevolutClient::buildUri(self::ENDPOINT);
70
-    }
62
+	/**
63
+	 * Get the Uri for the request
64
+	 * 
65
+	 * @return string
66
+	 */
67
+	public static function uri()
68
+	{
69
+		return RevolutClient::buildUri(self::ENDPOINT);
70
+	}
71 71
 
72
-    /**
73
-     * Build the client parameters
74
-     * The request must inlude the client ID, the client assertion (JWT) and client assertion type
75
-     * 
76
-     * @return array
77
-     */
78
-    private function buildClientParams()
79
-    {
80
-        return [
81
-            'client_assertion_type' => $this->clientAssertion::TYPE,
82
-            'client_id' => $this->clientAssertion->clientId,
83
-            'client_assertion' => $this->clientAssertion->build(),
84
-        ];
85
-    }
72
+	/**
73
+	 * Build the client parameters
74
+	 * The request must inlude the client ID, the client assertion (JWT) and client assertion type
75
+	 * 
76
+	 * @return array
77
+	 */
78
+	private function buildClientParams()
79
+	{
80
+		return [
81
+			'client_assertion_type' => $this->clientAssertion::TYPE,
82
+			'client_id' => $this->clientAssertion->clientId,
83
+			'client_assertion' => $this->clientAssertion->build(),
84
+		];
85
+	}
86 86
 
87
-    /**
88
-     * Build the grant parameters
89
-     * 
90
-     * @param \tbclla\Revolut\Interfaces\GrantsAccessTokens $requestToken
91
-     * @return array
92
-     */
93
-    private function buildGrantParams(GrantsAccessTokens $requestToken)
94
-    {
95
-        return [
96
-            'grant_type' => $requestToken->getGrantType(),
97
-            $requestToken->getType() => $requestToken->getValue(),
98
-        ];
99
-    }
87
+	/**
88
+	 * Build the grant parameters
89
+	 * 
90
+	 * @param \tbclla\Revolut\Interfaces\GrantsAccessTokens $requestToken
91
+	 * @return array
92
+	 */
93
+	private function buildGrantParams(GrantsAccessTokens $requestToken)
94
+	{
95
+		return [
96
+			'grant_type' => $requestToken->getGrantType(),
97
+			$requestToken->getType() => $requestToken->getValue(),
98
+		];
99
+	}
100 100
 }
Please login to merge, or discard this patch.
src/Auth/Requests/AuthorizationCodeRequest.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -4,113 +4,113 @@
 block discarded – undo
4 4
 
5 5
 class AuthorizationCodeRequest
6 6
 {
7
-    /**
8
-     * The sandbox URL
9
-     * 
10
-     * @var string
11
-     */
12
-    const SANDBOX_URL = 'https://sandbox-business.revolut.com';
7
+	/**
8
+	 * The sandbox URL
9
+	 * 
10
+	 * @var string
11
+	 */
12
+	const SANDBOX_URL = 'https://sandbox-business.revolut.com';
13 13
 
14
-    /**
15
-     * The production URL
16
-     * 
17
-     * @var string
18
-     */
19
-    const PRODUCTION_URL = 'https://business.revolut.com';
14
+	/**
15
+	 * The production URL
16
+	 * 
17
+	 * @var string
18
+	 */
19
+	const PRODUCTION_URL = 'https://business.revolut.com';
20 20
 
21
-    /**
22
-     * The app authorization endpoint
23
-     * 
24
-     * @var string
25
-     */
26
-    const ENDPOINT = '/app-confirm';
21
+	/**
22
+	 * The app authorization endpoint
23
+	 * 
24
+	 * @var string
25
+	 */
26
+	const ENDPOINT = '/app-confirm';
27 27
 
28
-    /**
29
-     * A token repository
30
-     *
31
-     * @var string The client Id
32
-     */
33
-    private $clientId;
28
+	/**
29
+	 * A token repository
30
+	 *
31
+	 * @var string The client Id
32
+	 */
33
+	private $clientId;
34 34
 
35
-    /**
36
-     * A token repository
37
-     *
38
-     * @var string The redirect URI
39
-     */
40
-    private $redirectUri;
35
+	/**
36
+	 * A token repository
37
+	 *
38
+	 * @var string The redirect URI
39
+	 */
40
+	private $redirectUri;
41 41
 
42
-    /**
43
-     * A token repository
44
-     *
45
-     * @var bool The environment
46
-     */
47
-    private $sandbox;
42
+	/**
43
+	 * A token repository
44
+	 *
45
+	 * @var bool The environment
46
+	 */
47
+	private $sandbox;
48 48
 
49
-    /**
50
-     * A state value
51
-     *
52
-     * @var string
53
-     */
54
-    public $state;
49
+	/**
50
+	 * A state value
51
+	 *
52
+	 * @var string
53
+	 */
54
+	public $state;
55 55
 
56
-    /**
57
-     * Create a new request
58
-     *
59
-     * @param string $clientId The Revolut Business Client ID
60
-     * @param string $redirectUri The OAuth redirect URI
61
-     * @param bool $sandbox Whether or not to use the sandbox environment
62
-     * @return void
63
-     */
64
-    public function __construct(string $clientId, string $redirectUri, bool $sandbox = true)
65
-    {
66
-        $this->clientId = $clientId;
67
-        $this->redirectUri = $redirectUri;
68
-        $this->sandbox = $sandbox;
69
-        $this->state = $this->generateState();
70
-    }
56
+	/**
57
+	 * Create a new request
58
+	 *
59
+	 * @param string $clientId The Revolut Business Client ID
60
+	 * @param string $redirectUri The OAuth redirect URI
61
+	 * @param bool $sandbox Whether or not to use the sandbox environment
62
+	 * @return void
63
+	 */
64
+	public function __construct(string $clientId, string $redirectUri, bool $sandbox = true)
65
+	{
66
+		$this->clientId = $clientId;
67
+		$this->redirectUri = $redirectUri;
68
+		$this->sandbox = $sandbox;
69
+		$this->state = $this->generateState();
70
+	}
71 71
 
72
-    /**
73
-     * Build the request
74
-     * 
75
-     * @return string
76
-     */
77
-    public function build()
78
-    {
79
-        return $this->baseUri() . self::ENDPOINT . '?' . $this->buildQuery();
80
-    }
72
+	/**
73
+	 * Build the request
74
+	 * 
75
+	 * @return string
76
+	 */
77
+	public function build()
78
+	{
79
+		return $this->baseUri() . self::ENDPOINT . '?' . $this->buildQuery();
80
+	}
81 81
 
82
-    /**
83
-     * Build the base URI
84
-     * 
85
-     * @return string
86
-     */
87
-    private function baseUri()
88
-    {
89
-        return $this->sandbox ? self::SANDBOX_URL : self::PRODUCTION_URL;
90
-    }
82
+	/**
83
+	 * Build the base URI
84
+	 * 
85
+	 * @return string
86
+	 */
87
+	private function baseUri()
88
+	{
89
+		return $this->sandbox ? self::SANDBOX_URL : self::PRODUCTION_URL;
90
+	}
91 91
 
92
-    /**
93
-     * Build the query
94
-     * 
95
-     * @return string
96
-     */
97
-    private function buildQuery()
98
-    {
99
-        return http_build_query([
100
-            'response_type' => 'request_token',
101
-            'client_id' => $this->clientId,
102
-            'redirect_uri' => $this->redirectUri,
103
-            'state' => $this->state
104
-        ]);
105
-    }
92
+	/**
93
+	 * Build the query
94
+	 * 
95
+	 * @return string
96
+	 */
97
+	private function buildQuery()
98
+	{
99
+		return http_build_query([
100
+			'response_type' => 'request_token',
101
+			'client_id' => $this->clientId,
102
+			'redirect_uri' => $this->redirectUri,
103
+			'state' => $this->state
104
+		]);
105
+	}
106 106
 
107
-    /**
108
-     * Generate a state value
109
-     *
110
-     * @return string
111
-     */
112
-    private function generateState()
113
-    {
114
-        return base64_encode(random_bytes(32));
115
-    }
107
+	/**
108
+	 * Generate a state value
109
+	 *
110
+	 * @return string
111
+	 */
112
+	private function generateState()
113
+	{
114
+		return base64_encode(random_bytes(32));
115
+	}
116 116
 }
Please login to merge, or discard this patch.
src/Auth/Token.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -16,95 +16,95 @@
 block discarded – undo
16 16
  */
17 17
 abstract class Token extends Model
18 18
 {
19
-    use Encryptable;
19
+	use Encryptable;
20 20
 
21
-    /**
22
-     * Whether or not to use timestamps
23
-     * 
24
-     * @var bool
25
-     */
26
-    public $timestamps = false;
21
+	/**
22
+	 * Whether or not to use timestamps
23
+	 * 
24
+	 * @var bool
25
+	 */
26
+	public $timestamps = false;
27 27
 
28
-    /**
29
-     * The attributes that are fillable
30
-     * 
31
-     * @var array
32
-     */
33
-    protected $fillable = ['value'];
28
+	/**
29
+	 * The attributes that are fillable
30
+	 * 
31
+	 * @var array
32
+	 */
33
+	protected $fillable = ['value'];
34 34
 
35
-    /**
36
-     * The attributes that should be cast to native types.
37
-     *
38
-     * @var array
39
-     */
40
-    protected $casts = [
41
-        'is_encrypted' => 'boolean',
42
-        'expires_at' => 'datetime',
43
-        'created_at' => 'datetime',
44
-    ];
35
+	/**
36
+	 * The attributes that should be cast to native types.
37
+	 *
38
+	 * @var array
39
+	 */
40
+	protected $casts = [
41
+		'is_encrypted' => 'boolean',
42
+		'expires_at' => 'datetime',
43
+		'created_at' => 'datetime',
44
+	];
45 45
 
46
-    /**
47
-     * The "booting" method of the model.
48
-     * 
49
-     * @return void
50
-     */
51
-    protected static function boot()
52
-    {
53
-        parent::boot();
46
+	/**
47
+	 * The "booting" method of the model.
48
+	 * 
49
+	 * @return void
50
+	 */
51
+	protected static function boot()
52
+	{
53
+		parent::boot();
54 54
 
55
-        static::creating(function($model) {
56
-            $model->type = static::getType();
57
-            $model->expires_at = static::getExpiration();
58
-        });
55
+		static::creating(function($model) {
56
+			$model->type = static::getType();
57
+			$model->expires_at = static::getExpiration();
58
+		});
59 59
         
60
-        static::addGlobalScope('type', function(Builder $builder) {
61
-            $builder->whereType(static::getType());
62
-        });
63
-    }
60
+		static::addGlobalScope('type', function(Builder $builder) {
61
+			$builder->whereType(static::getType());
62
+		});
63
+	}
64 64
 
65
-    /**
66
-     * Get the name of the tokens table
67
-     * 
68
-     * @return string
69
-     */
70
-    public function getTable()
71
-    {
72
-        return config('revolut.tokens.table_name');
73
-    }
65
+	/**
66
+	 * Get the name of the tokens table
67
+	 * 
68
+	 * @return string
69
+	 */
70
+	public function getTable()
71
+	{
72
+		return config('revolut.tokens.table_name');
73
+	}
74 74
 
75
-    /**
76
-     * Check if the token has expired
77
-     * 
78
-     * @return bool
79
-     */
80
-    public function hasExpired()
81
-    {
82
-        return $this->expires_at ? $this->expires_at < now() : false;
83
-    }
75
+	/**
76
+	 * Check if the token has expired
77
+	 * 
78
+	 * @return bool
79
+	 */
80
+	public function hasExpired()
81
+	{
82
+		return $this->expires_at ? $this->expires_at < now() : false;
83
+	}
84 84
 
85
-    /**
86
-     * Scope a query to only inlcude active tokens
87
-     * 
88
-     * @param  \Illuminate\Database\Eloquent\Builder  $query
89
-     * @param bool  $isActive
90
-     * @return  \Illuminate\Database\Eloquent\Builder
91
-     */
92
-    public function scopeActive($query, bool $isActive = true)
93
-    {
94
-        $col = 'expires_at';
85
+	/**
86
+	 * Scope a query to only inlcude active tokens
87
+	 * 
88
+	 * @param  \Illuminate\Database\Eloquent\Builder  $query
89
+	 * @param bool  $isActive
90
+	 * @return  \Illuminate\Database\Eloquent\Builder
91
+	 */
92
+	public function scopeActive($query, bool $isActive = true)
93
+	{
94
+		$col = 'expires_at';
95 95
 
96
-        return $isActive 
97
-            ? $query->where($col, '>', now())->orWhereNull($col)
98
-            : $query->where($col, '<=', now());
99
-    }
96
+		return $isActive 
97
+			? $query->where($col, '>', now())->orWhereNull($col)
98
+			: $query->where($col, '<=', now());
99
+	}
100 100
 
101
-    /**
102
-     * Delete all expired access tokens
103
-     * 
104
-     * @return int The number of deleted tokens
105
-     */
106
-    public static function clearExpired()
107
-    {
108
-        return (int) self::active(false)->delete();
109
-    }
101
+	/**
102
+	 * Delete all expired access tokens
103
+	 * 
104
+	 * @return int The number of deleted tokens
105
+	 */
106
+	public static function clearExpired()
107
+	{
108
+		return (int) self::active(false)->delete();
109
+	}
110 110
 }
Please login to merge, or discard this patch.
src/Auth/AccessToken.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@
 block discarded – undo
7 7
 
8 8
 class AccessToken extends Token implements PersistableToken
9 9
 {
10
-    /**
11
-     * The name of the token
12
-     * 
13
-     * @var string
14
-     */
15
-    const TYPE = 'access_token';
10
+	/**
11
+	 * The name of the token
12
+	 * 
13
+	 * @var string
14
+	 */
15
+	const TYPE = 'access_token';
16 16
 
17
-    /**
18
-     * The time to live in minutes
19
-     * 
20
-     * @var int
21
-     */
22
-    const TTL = 40;
17
+	/**
18
+	 * The time to live in minutes
19
+	 * 
20
+	 * @var int
21
+	 */
22
+	const TTL = 40;
23 23
 
24
-    public static function getType()
25
-    {
26
-        return self::TYPE;
27
-    }
24
+	public static function getType()
25
+	{
26
+		return self::TYPE;
27
+	}
28 28
 
29
-    public static function getExpiration()
30
-    {
31
-        return now()->addMinutes(self::TTL);
32
-    }
29
+	public static function getExpiration()
30
+	{
31
+		return now()->addMinutes(self::TTL);
32
+	}
33 33
 }
Please login to merge, or discard this patch.
src/Auth/RefreshToken.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -8,49 +8,49 @@
 block discarded – undo
8 8
 
9 9
 class RefreshToken extends Token implements GrantsAccessTokens, PersistableToken
10 10
 {
11
-    /**
12
-     * The type of the token
13
-     * 
14
-     * @var string
15
-     */
16
-    const TYPE = 'refresh_token';
17
-
18
-    /**
19
-     * The grant type of the token
20
-     * 
21
-     * @var string
22
-     */
23
-    const GRANT_TYPE = 'refresh_token';
24
-
25
-    public function getValue()
26
-    {
27
-        return $this->value;
28
-    }
29
-
30
-    public static function getType()
31
-    {
32
-        return self::TYPE;
33
-    }
34
-
35
-    public static function getGrantType()
36
-    {
37
-        return self::GRANT_TYPE;
38
-    }
39
-
40
-    public static function getExpiration()
41
-    {
42
-        return null;
43
-    }
44
-
45
-    /**
46
-     * Delete all expired refresh tokens
47
-     * 
48
-     * @return int The number of deleted tokens
49
-     */
50
-    public static function clearExpired()
51
-    {
52
-        $latest = self::latest()->select('id')->first();
53
-
54
-        return (int) self::where('id', '!=', $latest->id)->delete();
55
-    }
11
+	/**
12
+	 * The type of the token
13
+	 * 
14
+	 * @var string
15
+	 */
16
+	const TYPE = 'refresh_token';
17
+
18
+	/**
19
+	 * The grant type of the token
20
+	 * 
21
+	 * @var string
22
+	 */
23
+	const GRANT_TYPE = 'refresh_token';
24
+
25
+	public function getValue()
26
+	{
27
+		return $this->value;
28
+	}
29
+
30
+	public static function getType()
31
+	{
32
+		return self::TYPE;
33
+	}
34
+
35
+	public static function getGrantType()
36
+	{
37
+		return self::GRANT_TYPE;
38
+	}
39
+
40
+	public static function getExpiration()
41
+	{
42
+		return null;
43
+	}
44
+
45
+	/**
46
+	 * Delete all expired refresh tokens
47
+	 * 
48
+	 * @return int The number of deleted tokens
49
+	 */
50
+	public static function clearExpired()
51
+	{
52
+		$latest = self::latest()->select('id')->first();
53
+
54
+		return (int) self::where('id', '!=', $latest->id)->delete();
55
+	}
56 56
 }
Please login to merge, or discard this patch.