@@ -34,7 +34,9 @@ Biblioteca para manejo de hooks en PHP.
34
34
35
35
## Requisitos
36
36
37
- Esta biblioteca es compatible con las versiones de PHP: 8.1.
37
+ - Sistema operativo: Linux | Windows.
38
+
39
+ - Versiones de PHP: 8.1 | 8.2.
38
40
39
41
## Instalación
40
42
@@ -62,44 +64,40 @@ git clone https://github.com/josantonius/php-hook.git
62
64
63
65
### Instancia Action
64
66
65
- ``` php
66
- use Josantonius\Hook\Action;
67
- ```
67
+ ` Josantonius\Hook\Action `
68
68
69
69
Obtener el nivel de prioridad de la acción:
70
70
71
71
``` php
72
- $action-> getPriority(): int
72
+ public function getPriority(): int;
73
73
```
74
74
75
75
Obtener el resultado de la llamada a la acción:
76
76
77
77
``` php
78
- $action-> getResult(): mixed
78
+ public function getResult(): mixed;
79
79
```
80
80
81
81
Comprueba si la acción se realiza solo una vez:
82
82
83
83
``` php
84
- $action-> isOnce(): bool
84
+ public function isOnce(): bool;
85
85
```
86
86
87
87
Comprueba si la acción ya se ha realizado:
88
88
89
89
``` php
90
- $action-> wasDone(): bool
90
+ public function wasDone(): bool;
91
91
```
92
92
93
93
### Clase Hook
94
94
95
- ``` php
96
- use Josantonius\Hook\Hook;
97
- ```
95
+ ` Josantonius\Hook\Hook `
98
96
99
97
Registrar nuevo gancho:
100
98
101
99
``` php
102
- $hook = new Hook( string $name);
100
+ public function __construct(private string $name);
103
101
```
104
102
105
103
Agregar acción en el gancho:
@@ -112,7 +110,7 @@ Agregar acción en el gancho:
112
110
*
113
111
* @return Action Acción agregada.
114
112
*/
115
- $hook-> addAction(callable $callback, int $priority = Priority::NORMAL): Action
113
+ public function addAction(callable $callback, int $priority = Priority::NORMAL): Action;
116
114
```
117
115
118
116
Agregar acción en el gancho una vez:
@@ -126,7 +124,7 @@ Agregar acción en el gancho una vez:
126
124
*
127
125
* @return Action Acción agregada.
128
126
*/
129
- $hook-> addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action
127
+ public function addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action;
130
128
```
131
129
132
130
Ejecutar las acciones agregadas al gancho:
@@ -138,7 +136,7 @@ Ejecutar las acciones agregadas al gancho:
138
136
*
139
137
* @return Action[] Acciones hechas.
140
138
*/
141
- $hook-> doActions(mixed ...$arguments): Action[]
139
+ public function doActions(mixed ...$arguments): array;
142
140
```
143
141
144
142
Comprueba si el gancho tiene acciones:
@@ -148,7 +146,7 @@ Comprueba si el gancho tiene acciones:
148
146
* Verdadero si el gancho tiene alguna acción incluso si la acción
149
147
* se ha hecho antes (acciones recurrentes creadas con addAction).
150
148
*/
151
- $hook-> hasActions(): bool
149
+ public function hasActions(): bool;
152
150
```
153
151
154
152
Comprueba si el gancho tiene acciones sin realizar:
@@ -157,7 +155,7 @@ Comprueba si el gancho tiene acciones sin realizar:
157
155
/**
158
156
* Verdadero si el gancho tiene alguna acción sin realizar.
159
157
*/
160
- $hook-> hasUndoneActions(): bool
158
+ public function hasUndoneActions(): bool;
161
159
```
162
160
163
161
Comprueba si las acciones se han realizado al menos una vez:
@@ -166,25 +164,27 @@ Comprueba si las acciones se han realizado al menos una vez:
166
164
/**
167
165
* Si doActions fue ejecutado al menos una vez.
168
166
*/
169
- $hook-> hasDoneActions(): bool
167
+ public function hasDoneActions(): bool;
170
168
```
171
169
172
170
Obtener el nombre del hook:
173
171
174
172
``` php
175
- $hook-> getName(): string
173
+ public function getName(): string;
176
174
```
177
175
178
- ### Priority Class
176
+ ### Clase Priority
177
+
178
+ ` Josantonius\Hook\Priority `
179
179
180
180
Constantes disponibles:
181
181
182
182
``` php
183
- Priority:: HIGHEST; // 50
184
- Priority:: HIGH; // 100
185
- Priority:: NORMAL; // 150
186
- Priority:: LOW; // 200
187
- Priority:: LOWEST; // 250
183
+ public const HIGHEST = 50;
184
+ public const HIGH = 100;
185
+ public const NORMAL = 150;
186
+ public const LOW = 200;
187
+ public const LOWEST = 250;
188
188
```
189
189
190
190
## Excepciones utilizadas
0 commit comments