1<?php
2
3namespace OAuth\Common\Storage;
4
5use OAuth\Common\Token\TokenInterface;
6use OAuth\Common\Storage\Exception\TokenNotFoundException;
7
8/**
9 * All token storage providers must implement this interface.
10 */
11interface TokenStorageInterface
12{
13    /**
14     * @param string $service
15     *
16     * @return TokenInterface
17     *
18     * @throws TokenNotFoundException
19     */
20    public function retrieveAccessToken($service);
21
22    /**
23     * @param string         $service
24     * @param TokenInterface $token
25     *
26     * @return TokenStorageInterface
27     */
28    public function storeAccessToken($service, TokenInterface $token);
29
30    /**
31     * @param string $service
32     *
33     * @return bool
34     */
35    public function hasAccessToken($service);
36
37    /**
38     * Delete the users token. Aka, log out.
39     *
40     * @param string $service
41     *
42     * @return TokenStorageInterface
43     */
44    public function clearToken($service);
45
46    /**
47     * Delete *ALL* user tokens. Use with care. Most of the time you will likely
48     * want to use clearToken() instead.
49     *
50     * @return TokenStorageInterface
51     */
52    public function clearAllTokens();
53
54    /**
55     * Store the authorization state related to a given service
56     *
57     * @param string $service
58     * @param string $state
59     *
60     * @return TokenStorageInterface
61     */
62    public function storeAuthorizationState($service, $state);
63
64    /**
65     * Check if an authorization state for a given service exists
66     *
67     * @param string $service
68     *
69     * @return bool
70     */
71    public function hasAuthorizationState($service);
72
73    /**
74     * Retrieve the authorization state for a given service
75     *
76     * @param string $service
77     *
78     * @return string
79     */
80    public function retrieveAuthorizationState($service);
81
82    /**
83     * Clear the authorization state of a given service
84     *
85     * @param string $service
86     *
87     * @return TokenStorageInterface
88     */
89    public function clearAuthorizationState($service);
90
91    /**
92     * Delete *ALL* user authorization states. Use with care. Most of the time you will likely
93     * want to use clearAuthorization() instead.
94     *
95     * @return TokenStorageInterface
96     */
97    public function clearAllAuthorizationStates();
98}
99