-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIAuthority.php
More file actions
52 lines (46 loc) · 1.71 KB
/
IAuthority.php
File metadata and controls
52 lines (46 loc) · 1.71 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
<?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\Authorization;
/**
* Defines the interface for authorities to implement
*/
interface IAuthority
{
/**
* Checks if a subject has a permission
*
* @param string $permission The permission being sought
* @param array ...$arguments The noncompulsory list of arguments to use when considering permission
* @return bool True if the subject has the input permission, otherwise false
*/
public function can(string $permission, ...$arguments) : bool;
/**
* Checks if a subject does not have a permission
*
* @param string $permission The permission being sought
* @param array ...$arguments The noncompulsory list of arguments to use when considering permission
* @return bool True if the subject does not have the input permission, otherwise false
*/
public function cannot(string $permission, ...$arguments) : bool;
/**
* Creates an instance of this class for a given subject
*
* @param mixed $subjectId The primary identity of the subject to check
* @param array $subjectRoles The list of role names the subject has
* @return IAuthority The instance for the input subject
*/
public function forSubject($subjectId, array $subjectRoles) : IAuthority;
/**
* Sets the subject of the authority
*
* @param mixed $subjectId The primary identity of the subject to check
* @param array $subjectRoles The list of role names the subject has
*/
public function setSubject($subjectId, array $subjectRoles);
}