Skip to content

Commit 00f9d61

Browse files
authored
Merge pull request #1 from josantonius/pre-release/v1.0.3
pre-release/v1.0.3
2 parents b7eb3ac + a059806 commit 00f9d61

File tree

7 files changed

+58
-66
lines changed

7 files changed

+58
-66
lines changed

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

+10-15
Original file line numberDiff line numberDiff line change
@@ -61,39 +61,34 @@ git clone https://github.com/josantonius/php-exception-handler.git
6161

6262
### Clase ExceptionHandler
6363

64-
```php
65-
use Josantonius\ExceptionHandler\ExceptionHandler;
66-
```
64+
`Josantonius\ExceptionHandler\ExceptionHandler`
6765

6866
Establece un manejador de excepciones:
6967

7068
```php
7169
/**
7270
* Sets a exception handler.
7371
*
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.
72+
* @param callable $callback Exception handler function.
73+
* @param string[] $runBeforeCallback Method names to call in the exception before run callback.
74+
* @param string[] $runAfterCallback Method names to call in the exception after run callback.
7775
*
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.
76+
* @throws NotCallableException if the callback is not callable.
77+
* @throws WrongMethodNameException if the method names are not string or are empty.
8078
*
8179
* @see https://www.php.net/manual/en/functions.first_class_callable_syntax.php
8280
*/
83-
new ExceptionHandler(
84-
callable $callback,
85-
string[] $runBeforeCallback = [],
86-
string[] $runAfterCallback = []
81+
public function __construct(
82+
private callable $callback,
83+
private array $runBeforeCallback = [],
84+
private array $runAfterCallback = []
8785
);
8886
```
8987

9088
## Excepciones utilizadas
9189

9290
```php
9391
use Josantonius\ExceptionHandler\Exceptions\NotCallableException;
94-
```
95-
96-
```php
9792
use Josantonius\ExceptionHandler\Exceptions\WrongMethodNameException;
9893
```
9994

README.md

+8-13
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ PHP library for handling exceptions.
2525
- [TODO](#todo)
2626
- [Changelog](#changelog)
2727
- [Contribution](#contribution)
28-
- [Sponsor](#Sponsor)
28+
- [Sponsor](#sponsor)
2929
- [License](#license)
3030

3131
---
@@ -61,9 +61,7 @@ git clone https://github.com/josantonius/php-exception-handler.git
6161

6262
### ExceptionHandler Class
6363

64-
```php
65-
use Josantonius\ExceptionHandler\ExceptionHandler;
66-
```
64+
`Josantonius\ExceptionHandler\ExceptionHandler`
6765

6866
Sets a exception handler:
6967

@@ -72,28 +70,25 @@ Sets a exception handler:
7270
* Sets a exception handler.
7371
*
7472
* @param callable $callback Exception handler function.
75-
* @param array $runBeforeCallback Method names to call in the exception before run callback.
76-
* @param array $runAfterCallback Method names to call in the exception after run callback.
73+
* @param string[] $runBeforeCallback Method names to call in the exception before run callback.
74+
* @param string[] $runAfterCallback Method names to call in the exception after run callback.
7775
*
7876
* @throws NotCallableException if the callback is not callable.
7977
* @throws WrongMethodNameException if the method names are not string or are empty.
8078
*
8179
* @see https://www.php.net/manual/en/functions.first_class_callable_syntax.php
8280
*/
83-
new ExceptionHandler(
84-
callable $callback,
85-
string[] $runBeforeCallback = [],
86-
string[] $runAfterCallback = []
81+
public function __construct(
82+
private callable $callback,
83+
private array $runBeforeCallback = [],
84+
private array $runAfterCallback = []
8785
);
8886
```
8987

9088
## Exceptions Used
9189

9290
```php
9391
use Josantonius\ExceptionHandler\Exceptions\NotCallableException;
94-
```
95-
96-
```php
9792
use Josantonius\ExceptionHandler\Exceptions\WrongMethodNameException;
9893
```
9994

phpmd.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<rule ref="rulesets/controversial.xml/Superglobals" />
3333
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
3434
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
35-
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
35+
<!--<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>-->
3636
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
3737
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
3838

src/ExceptionHandler.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
declare(strict_types=1);
44

55
/*
6-
* This file is part of https://github.com/josantonius/php-exception-handler repository.
7-
*
8-
* (c) Josantonius <[email protected]>
9-
*
10-
* For the full copyright and license information, please view the LICENSE
11-
* file that was distributed with this source code.
12-
*/
6+
* This file is part of https://github.com/josantonius/php-exception-handler repository.
7+
*
8+
* (c) Josantonius <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
1313

1414
namespace Josantonius\ExceptionHandler;
1515

src/Exceptions/NotCallableException.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-exception-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-exception-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
1111

1212
namespace Josantonius\ExceptionHandler\Exceptions;
1313

src/Exceptions/WrongMethodNameException.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-exception-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-exception-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
1111

1212
namespace Josantonius\ExceptionHandler\Exceptions;
1313

tests/ExceptionHandlerTest.php

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-exception-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-exception-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12+
*/
1113

1214
namespace Josantonius\ErrorHandler\Tests;
1315

@@ -31,14 +33,14 @@ public function setUp(): void
3133
$this->handler = new Handler();
3234
}
3335

34-
public function testShouldFailIfCallableCallbackIsNotPassed(): void
36+
public function test_should_fail_if_callable_callback_is_not_passed(): void
3537
{
3638
$this->expectException(NotCallableException::class);
3739

3840
new ExceptionHandler(callback: 'foo');
3941
}
4042

41-
public function testShouldFailIfTheMethodNamesNotContainValidDataType(): void
43+
public function test_should_fail_if_the_method_names_not_contain_valid_data_type(): void
4244
{
4345
$this->expectException(WrongMethodNameException::class);
4446

@@ -48,15 +50,15 @@ public function testShouldFailIfTheMethodNamesNotContainValidDataType(): void
4850
);
4951
}
5052

51-
public function testShouldSetTheHandlerOnlyWithTheCallback(): void
53+
public function test_should_set_the_handler_only_with_the_callback(): void
5254
{
5355
$this->assertInstanceOf(
5456
ExceptionHandler::class,
5557
new ExceptionHandler(callback: $this->handler->init(...))
5658
);
5759
}
5860

59-
public function testShouldSetTheHandlerOnlyWithCallsToRunBefore(): void
61+
public function test_should_set_the_handler_only_with_calls_to_run_before(): void
6062
{
6163
$this->assertInstanceOf(
6264
ExceptionHandler::class,
@@ -67,7 +69,7 @@ public function testShouldSetTheHandlerOnlyWithCallsToRunBefore(): void
6769
);
6870
}
6971

70-
public function testShouldSetTheHandlerOnlyWithCallsToAfter(): void
72+
public function test_should_set_the_handler_only_with_calls_to_after(): void
7173
{
7274
$this->assertInstanceOf(
7375
ExceptionHandler::class,
@@ -78,7 +80,7 @@ public function testShouldSetTheHandlerOnlyWithCallsToAfter(): void
7880
);
7981
}
8082

81-
public function testShouldCallTheCallbackWhenAnExceptionIsThrow(): void
83+
public function test_should_call_the_callback_when_an_exception_is_throw(): void
8284
{
8385
$exceptionHandler = new ExceptionHandler(callback: $this->handler->init(...));
8486

@@ -94,7 +96,7 @@ public function testShouldCallTheCallbackWhenAnExceptionIsThrow(): void
9496
$this->assertEquals('init', History::get(0)->methodName);
9597
}
9698

97-
public function testShouldCallTheCallbackBeforeRunMethodsWhenAnExceptionIsThrow(): void
99+
public function test_should_call_the_callback_before_run_methods_when_exception_is_throw(): void
98100
{
99101
$exceptionHandler = new ExceptionHandler(
100102
callback: $this->handler->init(...),
@@ -113,7 +115,7 @@ public function testShouldCallTheCallbackBeforeRunMethodsWhenAnExceptionIsThrow(
113115
$this->assertEquals('context', History::get(0)->methodName);
114116
}
115117

116-
public function testShouldCallTheCallbackAfterRunMethodsWhenAnExceptionIsThrow(): void
118+
public function test_should_call_the_callback_after_run_methods_when_exception_is_throw(): void
117119
{
118120
$exceptionHandler = new ExceptionHandler(
119121
callback: $this->handler->init(...),
@@ -134,7 +136,7 @@ public function testShouldCallTheCallbackAfterRunMethodsWhenAnExceptionIsThrow()
134136
$this->assertEquals('render', History::get(2)->methodName);
135137
}
136138

137-
public function testShouldCallTheCallbackAfterAndBeforeRunMethodsWhenAnExceptionIsThrow(): void
139+
public function test_should_call_callback_and_all_methods_when_an_exception_is_throw(): void
138140
{
139141
$exceptionHandler = new ExceptionHandler(
140142
callback: $this->handler->init(...),

0 commit comments

Comments
 (0)