-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISubject.php
More file actions
85 lines (73 loc) · 2.01 KB
/
ISubject.php
File metadata and controls
85 lines (73 loc) · 2.01 KB
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
<?php
/*
* Opulence
*
* @link https://www.opulencephp.com
* @copyright Copyright (C) 2021 David Young
* @license https://github.com/opulencephp/Opulence/blob/1.2/LICENSE.md
*/
namespace Opulence\Authentication;
use Opulence\Authentication\Credentials\ICredential;
/**
* Defines the interface for subjects to implement
*/
interface ISubject
{
/**
* Adds a credential
*
* @param ICredential $credential The credential to add
*/
public function addCredential(ICredential $credential);
/**
* Adds a principal
*
* @param IPrincipal $principal The principal to add
*/
public function addPrincipal(IPrincipal $principal);
/**
* Gets the credential with the input type
*
* @param string $type The credential type
* @return ICredential|null The credential, if there was one, otherwise null
*/
public function getCredential(string $type);
/**
* Gets the list of credentials this subject has
*
* @return array The list of credentials
*/
public function getCredentials() : array;
/**
* Gets the primary principal
*
* @return IPrincipal|null The primary principal
*/
public function getPrimaryPrincipal();
/**
* Gets the principal with the input type
*
* @param string $type The principal type
* @return IPrincipal|null The principal, if there was one, otherwise null
*/
public function getPrincipal(string $type);
/**
* Gets the list of all principals
*
* @return IPrincipal[] The list of all principals
*/
public function getPrincipals() : array;
/**
* Gets the list of role names
*
* @return array The list of role names
*/
public function getRoles() : array;
/**
* Gets whether or not a subject has a role
*
* @param string $roleName The role to check for
* @return bool True if the subject has a role, otherwise false
*/
public function hasRole(string $roleName) : bool;
}