/
StoreInterface.php
106 lines (90 loc) · 2.45 KB
/
StoreInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
declare(strict_types=1);
namespace SilverStripe\MFA\Store;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\MFA\Extension\MemberExtension;
use SilverStripe\Security\Member;
/**
* Represents a place for temporarily storing state related to a login or registration attempt.
*/
interface StoreInterface
{
/**
* Create a new StoreInterface, optionally given an HTTPRequest object
*
* @param Member $member
*/
public function __construct(Member $member);
/**
* Persist the stored state for the given request
*
* @param HTTPRequest $request
* @return StoreInterface
*/
public function save(HTTPRequest $request): StoreInterface;
/**
* Load a StoreInterface from the given request and return it if it exists
*
* @param HTTPRequest $request
* @return StoreInterface|null
*/
public static function load(HTTPRequest $request): ?StoreInterface;
/**
* Clear any stored state for the given request
*
* @param HTTPRequest $request
* @return void
*/
public static function clear(HTTPRequest $request): void;
/**
* Get the state from the store
*
* @return array
*/
public function getState(): array;
/**
* Update the state in the store. Will override existing state. To add to the existing state use addState().
*
* @param array $state
* @return StoreInterface
*/
public function setState(array $state): StoreInterface;
/**
* Add to the state in the store
*
* @param array $state
* @return StoreInterface
*/
public function addState(array $state): StoreInterface;
/**
* @return Member&MemberExtension|null
*/
public function getMember(): ?Member;
/**
* @param Member $member
* @return $this
*/
public function setMember(Member $member): StoreInterface;
/**
* @return string
*/
public function getMethod(): ?string;
/**
* @param string|null $method
* @return $this
*/
public function setMethod(?string $method): StoreInterface;
/**
* Add and keep track of methods that have been verified
*
* @param string $method
* @return StoreInterface
*/
public function addVerifiedMethod(string $method): StoreInterface;
/**
* Get the list of methods that have been verified
*
* @return string[]
*/
public function getVerifiedMethods(): array;
}