5
5
use Symfony \Component \Security \Core \Authorization \AuthorizationCheckerInterface ;
6
6
7
7
/**
8
- * Class HistoryConfiguration
9
- *
10
8
* Based on the work of
11
9
* SimpleThings\EntityAudit
12
10
* Benjamin Eberlei <[email protected] >
16
14
*/
17
15
class HistoryConfiguration
18
16
{
19
-
20
17
// Configuration variables
21
18
protected $ classes ;
22
19
protected $ prefix ;
@@ -26,70 +23,37 @@ class HistoryConfiguration
26
23
protected $ deletedAtField ;
27
24
protected $ deletedByField ;
28
25
protected $ deletedByMethod ;
29
-
30
- /**
31
- * @var array
32
- */
33
- private $ changes = array ();
26
+ private array $ changes = [];
34
27
35
28
public function __construct (private readonly AuthorizationCheckerInterface $ authorizationChecker ) {
36
29
}
37
30
38
- /**
39
- * @return mixed
40
- */
41
- public function getClasses () {
31
+ public function getClasses (): mixed {
42
32
return $ this ->classes ;
43
33
}
44
34
45
- /**
46
- * @return mixed
47
- */
48
- public function getPrefix () {
35
+ public function getPrefix (): mixed {
49
36
return $ this ->prefix ;
50
37
}
51
38
52
- /**
53
- * @return mixed
54
- */
55
- public function getRevisionFieldName () {
39
+ public function getRevisionFieldName (): mixed {
56
40
return $ this ->revisionFieldName ;
57
41
}
58
42
59
- /**
60
- * @return mixed
61
- */
62
- public function getRevisionTypeFieldName () {
43
+ public function getRevisionTypeFieldName (): mixed {
63
44
return $ this ->revisionTypeFieldName ;
64
45
}
65
46
66
- /**
67
- * @return mixed
68
- */
69
- public function getSuffix () {
47
+ public function getSuffix (): mixed {
70
48
return $ this ->suffix ;
71
49
}
72
50
73
- /**
74
- * @param $class
75
- *
76
- * @return string
77
- */
78
- public function getTableName ($ class ) {
51
+ public function getTableName ($ class ): string {
79
52
return $ this ->prefix . $ class . $ this ->suffix ;
80
53
}
81
54
82
- /**
83
- * @param $prefix
84
- * @param $suffix
85
- * @param $revFieldName
86
- * @param $revTypeFieldName
87
- * @param $classes
88
- * @param $deletedAtField
89
- * @param $deletedByField
90
- * @param $deletedByMethod
91
- */
92
- public function injectVars ($ prefix , $ suffix , $ revFieldName , $ revTypeFieldName , $ classes , $ deletedAtField , $ deletedByField , $ deletedByMethod ) {
55
+ public function injectVars ($ prefix , $ suffix , $ revFieldName , $ revTypeFieldName , $ classes , $ deletedAtField , $ deletedByField , $ deletedByMethod ): void
56
+ {
93
57
$ this ->prefix = $ prefix ;
94
58
$ this ->suffix = $ suffix ;
95
59
$ this ->revisionFieldName = $ revFieldName ;
@@ -100,33 +64,19 @@ public function injectVars($prefix, $suffix, $revFieldName, $revTypeFieldName, $
100
64
$ this ->deletedByMethod = $ deletedByMethod ;
101
65
}
102
66
103
- /**
104
- * @param $entityName
105
- *
106
- * @return mixed
107
- */
108
- public function isLogged ($ entityName ) {
67
+ public function isLogged ($ entityName ): bool {
109
68
return array_key_exists ($ entityName , $ this ->classes );
110
69
}
111
70
112
- /**
113
- * @return mixed
114
- */
115
- public function getDeletedAtField () {
71
+ public function getDeletedAtField (): mixed {
116
72
return $ this ->deletedAtField ;
117
73
}
118
74
119
- /**
120
- * @return mixed
121
- */
122
- public function getDeletedByField () {
75
+ public function getDeletedByField (): mixed {
123
76
return $ this ->deletedByField ;
124
77
}
125
78
126
- /**
127
- * @return mixed
128
- */
129
- public function getDeletedByValue () {
79
+ public function getDeletedByValue (): mixed {
130
80
$ method = $ this ->deletedByMethod ;
131
81
try {
132
82
return $ this ->authorizationChecker ->$ method ();
@@ -135,13 +85,7 @@ public function getDeletedByValue() {
135
85
}
136
86
}
137
87
138
- /**
139
- * @param $className
140
- * @param $id
141
- *
142
- * @return bool
143
- */
144
- public function isReverted ($ className , $ id ) {
88
+ public function isReverted ($ className , $ id ): bool {
145
89
if (isset ($ this ->changes [$ className ]) && in_array ($ id , $ this ->changes [$ className ])) {
146
90
unset($ this ->changes [$ className ][$ id ]);
147
91
return true ;
@@ -150,15 +94,10 @@ public function isReverted($className, $id) {
150
94
return false ;
151
95
}
152
96
153
- /**
154
- * @param $className
155
- * @param $id
156
- */
157
- public function setReverted ($ className , $ id ) {
97
+ public function setReverted ($ className , $ id ): void {
158
98
if (!isset ($ this ->changes [$ className ])) {
159
99
$ this ->changes [$ className ] = [];
160
100
}
161
101
$ this ->changes [$ className ][] = $ id ;
162
102
}
163
-
164
103
}
0 commit comments