Skip to content

Commit 021e691

Browse files
committed
docs: improve readme files
1 parent f806a43 commit 021e691

File tree

2 files changed

+143
-130
lines changed

2 files changed

+143
-130
lines changed

.github/lang/es-ES/README.md

Lines changed: 73 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ Biblioteca PHP para manejar excepciones.
1717

1818
- [Instalación](#instalación)
1919
- [Requisitos](#requisitos)
20-
- [Cómo empezar y ejemplos](#cómo-empezar-y-ejemplos)
21-
- [Métodos disponibles](#métodos-disponibles)
20+
- [Clases disponibles](#clases-disponibles)
21+
- [Clase ExceptionHandler](#clase-exceptionhandler)
22+
- [Excepciones utilizadas](#excepciones-utilizadas)
2223
- [Uso](#uso)
2324
- [Tests](#tests)
2425
- [Tareas pendientes](#tareas-pendientes)
@@ -56,43 +57,44 @@ También puedes **clonar el repositorio** completo con Git:
5657
git clone https://github.com/josantonius/php-exception-handler.git
5758
```
5859

59-
## Métodos disponibles
60+
## Clases disponibles
6061

61-
Métodos disponibles en esta biblioteca:
62+
### Clase ExceptionHandler
6263

63-
### Establece un manejador de excepciones
64+
```php
65+
use Josantonius\ExceptionHandler\ExceptionHandler;
66+
```
67+
68+
Establece un manejador de excepciones:
6469

6570
```php
71+
/**
72+
* Sets a exception handler.
73+
*
74+
* @param callable $callback Función para manejo de excepciones.
75+
* @param array $runBeforeCallback Métodos a llamar en la excepción antes del callback.
76+
* @param array $runAfterCallback Métodos a llamar en la excepción después del callback.
77+
*
78+
* @throws NotCallableException si la llamada de retorno no es de tipo callable.
79+
* @throws WrongMethodNameException si el nombre del método no es string o está vacío.
80+
*
81+
* @see https://www.php.net/manual/en/functions.first_class_callable_syntax.php
82+
*/
6683
new ExceptionHandler(
6784
callable $callback,
6885
string[] $runBeforeCallback = [],
6986
string[] $runAfterCallback = []
7087
);
7188
```
7289

73-
**@param** callable `$callback` Función para manejo de excepciones.
74-
75-
**@param** array `$runBeforeCallback` Nombres de métodos a llamar en la excepción antes de
76-
ejecutar el *callback*.
77-
78-
**@param** array `$runAfterCallback` Nombres de métodos a llamar en la excepción después de
79-
ejecutar el *callback*.
80-
81-
**@throws** `NotCallableException` si la llamada de retorno no es de tipo *callable*.
82-
83-
**@throws** `WrongMethodNameException` si el nombre del método no es *string*.
84-
85-
@see <https://www.php.net/manual/en/functions.first_class_callable_syntax.php> para más información
86-
sobre la sintaxis de las llamadas de primera clase.
87-
88-
## Cómo empezar
89-
90-
Para utilizar esta biblioteca:
90+
## Excepciones utilizadas
9191

9292
```php
93-
use Josantonius\ExceptionHandler\ExceptionHandler;
93+
use Josantonius\ExceptionHandler\Exceptions\NotCallableException;
94+
```
9495

95-
new ExceptionHandler(/*...*/);
96+
```php
97+
use Josantonius\ExceptionHandler\Exceptions\WrongMethodNameException;
9698
```
9799

98100
## Uso
@@ -102,29 +104,31 @@ Ejemplo de uso para esta biblioteca:
102104
### Establece un manejador de excepciones básico
103105

104106
```php
105-
function handler(Throwable $exception) { /* hacer algo */ }
106-
```
107+
use Josantonius\ExceptionHandler\ExceptionHandler;
108+
109+
function handler(\Throwable $exception) { /* hacer algo */ }
107110

108-
```php
109111
new ExceptionHandler(
110112
callback: handler(...)
111113
);
112-
```
113-
114-
Si se lanza una excepción:
115114

116-
- `handler($exception)` *callback* será ejecutado
115+
/**
116+
* Si se lanza una excepción, se ejecuta lo siguiente:
117+
*
118+
* handler($exception)
119+
*/
120+
```
117121

118122
### Establece los métodos a llamar antes de ejecutar el *callback*
119123

120124
```php
125+
use Josantonius\ExceptionHandler\ExceptionHandler;
126+
121127
class FooException extends \Exception
122128
{
123129
public function context(): void { /* hacer algo */ }
124130
}
125-
```
126131

127-
```php
128132
class Handler {
129133
public function exceptions(Throwable $exception): void
130134
{
@@ -133,32 +137,32 @@ class Handler {
133137
}
134138
}
135139
}
136-
```
137140

138-
```php
139141
new ExceptionHandler(
140142
callback: (new Handler())->exceptions(...),
141143
runBeforeCallback: ['context']
142144
);
143-
```
144145

145-
Si se lanza `FooException()`:
146-
147-
- `FooException->context()` será llamado
148-
- `Handler->exceptions($exception)` *callback* será ejecutado
146+
/**
147+
* Si se lanza FooException(), se ejecuta lo siguiente:
148+
*
149+
* FooException->context()
150+
* Handler->exceptions($exception)
151+
*/
152+
```
149153

150-
### Sets methods to execute after calling the callback
154+
### Establece los métodos a ejecutar después de llamar al *callback*
151155

152156
```php
157+
use Josantonius\ExceptionHandler\ExceptionHandler;
158+
153159
class FooException extends \Exception
154160
{
155161
public function report(): void { /* hacer algo */ }
156162

157163
public function render(): void { /* hacer algo */ }
158164
}
159-
```
160165

161-
```php
162166
class Handler {
163167
public static function exceptions(Throwable $exception): void
164168
{
@@ -167,53 +171,54 @@ class Handler {
167171
}
168172
}
169173
}
170-
```
171174

172-
```php
173175
new ExceptionHandler(
174176
callback: Handler::exceptions(...),
175177
runAfterCallback: ['report', 'render']
176178
);
177-
```
178-
179-
Si se lanza `FooException()`:
180179

181-
- `Handler::exceptions($exception)` *callback* será ejecutado
182-
- `FooException->report()` será llamado
183-
- `FooException->render()` será llamado
180+
/**
181+
* Si se lanza FooException(), se ejecuta lo siguiente:
182+
*
183+
* Handler::exceptions($exception)
184+
* FooException->report()
185+
* FooException->render()
186+
*/
187+
```
184188

185189
### Sets methods to execute before and after calling the callback
186190

187191
```php
192+
use Josantonius\ExceptionHandler\ExceptionHandler;
193+
188194
class FooException extends \Exception
189195
{
190-
public function context(): void { /* hacer algo */ }
196+
public function context(): void { /* do something */ }
191197

192-
public function report(): void { /* hacer algo */ }
198+
public function report(): void { /* do something */ }
193199

194-
public function render(): void { /* hacer algo */ }
200+
public function render(): void { /* do something */ }
195201
}
196-
```
197202

198-
```php
199-
function exceptionHandler(Throwable $exception) { /* hacer algo */ }
200-
```
203+
function exceptionHandler(Throwable $exception) { /* do something */ }
201204

202-
```php
203205
new ExceptionHandler(
204206
callback: exceptionHandler(...),
205207
runBeforeCallback: ['context', 'logger'],
206208
runAfterCallback: ['report', 'render']
207209
);
208-
```
209-
210-
Si se lanza `FooException()`:
211210

212-
- `FooException->context()` será llamado
213-
- `FooException->logger()` será ignorado, no existe en la excepción
214-
- `exceptionHandler($exception)` *callback* será ejecutado
215-
- `FooException->report()` será llamado
216-
- `FooException->render()` será llamado
211+
/**
212+
* If FooException() is thrown, the following is executed:
213+
*
214+
* FooException->context()
215+
* exceptionHandler($exception)
216+
* FooException->report()
217+
* FooException->render()
218+
*
219+
* Se ignora FooException->logger(), no existe en la excepción.
220+
*/
221+
```
217222

218223
## Tests
219224

0 commit comments

Comments
 (0)