Skip to content

Commit

Permalink
docs: add functions to document methods
Browse files Browse the repository at this point in the history
Functions were added to document the methods and avoid confusion.

Closes #4
  • Loading branch information
josantonius committed Aug 27, 2022
1 parent 3db6ba4 commit 505c22a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 51 deletions.
46 changes: 22 additions & 24 deletions .github/lang/es-ES/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,44 +62,40 @@ git clone https://github.com/josantonius/php-hook.git

### Instancia Action

```php
use Josantonius\Hook\Action;
```
`Josantonius\Hook\Action`

Obtener el nivel de prioridad de la acción:

```php
$action->getPriority(): int
public function getPriority(): int;
```

Obtener el resultado de la llamada a la acción:

```php
$action->getResult(): mixed
public function getResult(): mixed;
```

Comprueba si la acción se realiza solo una vez:

```php
$action->isOnce(): bool
public function isOnce(): bool;
```

Comprueba si la acción ya se ha realizado:

```php
$action->wasDone(): bool
public function wasDone(): bool;
```

### Clase Hook

```php
use Josantonius\Hook\Hook;
```
`Josantonius\Hook\Hook`

Registrar nuevo gancho:

```php
$hook = new Hook(string $name);
public function __construct(private string $name);
```

Agregar acción en el gancho:
Expand All @@ -112,7 +108,7 @@ Agregar acción en el gancho:
*
* @return Action Acción agregada.
*/
$hook->addAction(callable $callback, int $priority = Priority::NORMAL): Action
public function addAction(callable $callback, int $priority = Priority::NORMAL): Action;
```

Agregar acción en el gancho una vez:
Expand All @@ -126,7 +122,7 @@ Agregar acción en el gancho una vez:
*
* @return Action Acción agregada.
*/
$hook->addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action
public function addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action;
```

Ejecutar las acciones agregadas al gancho:
Expand All @@ -138,7 +134,7 @@ Ejecutar las acciones agregadas al gancho:
*
* @return Action[] Acciones hechas.
*/
$hook->doActions(mixed ...$arguments): Action[]
public function doActions(mixed ...$arguments): array;
```

Comprueba si el gancho tiene acciones:
Expand All @@ -148,7 +144,7 @@ Comprueba si el gancho tiene acciones:
* Verdadero si el gancho tiene alguna acción incluso si la acción
* se ha hecho antes (acciones recurrentes creadas con addAction).
*/
$hook->hasActions(): bool
public function hasActions(): bool;
```

Comprueba si el gancho tiene acciones sin realizar:
Expand All @@ -157,7 +153,7 @@ Comprueba si el gancho tiene acciones sin realizar:
/**
* Verdadero si el gancho tiene alguna acción sin realizar.
*/
$hook->hasUndoneActions(): bool
public function hasUndoneActions(): bool;
```

Comprueba si las acciones se han realizado al menos una vez:
Expand All @@ -166,25 +162,27 @@ Comprueba si las acciones se han realizado al menos una vez:
/**
* Si doActions fue ejecutado al menos una vez.
*/
$hook->hasDoneActions(): bool
public function hasDoneActions(): bool;
```

Obtener el nombre del hook:

```php
$hook->getName(): string
public function getName(): string;
```

### Priority Class
### Clase Priority

`Josantonius\Hook\Priority`

Constantes disponibles:

```php
Priority::HIGHEST; // 50
Priority::HIGH; // 100
Priority::NORMAL; // 150
Priority::LOW; // 200
Priority::LOWEST; // 250
public const HIGHEST = 50;
public const HIGH = 100;
public const NORMAL = 150;
public const LOW = 200;
public const LOWEST = 250;
```

## Excepciones utilizadas
Expand Down
48 changes: 21 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Library for handling hooks in PHP.
- [TODO](#todo)
- [Changelog](#changelog)
- [Contribution](#contribution)
- [Sponsor](#Sponsor)
- [Sponsor](#sponsor)
- [License](#license)

---
Expand Down Expand Up @@ -63,44 +63,40 @@ git clone https://github.com/josantonius/php-hook.git

### Action Instance

```php
use Josantonius\Hook\Action;
```
`Josantonius\Hook\Action`

Gets action priority:

```php
$action->getPriority(): int
public function getPriority(): int;
```

Gets action callback result:

```php
$action->getResult(): mixed
public function getResult(): mixed;
```

Checks if the action is done once:

```php
$action->isOnce(): bool
public function isOnce(): bool;
```

Checks if the action has already been done:

```php
$action->wasDone(): bool
public function wasDone(): bool;
```

### Hook Class

```php
use Josantonius\Hook\Hook;
```
`Josantonius\Hook\Hook`

Register new hook:

```php
$hook = new Hook(string $name);
public function __construct(private string $name);
```

Adds action on the hook:
Expand All @@ -113,7 +109,7 @@ Adds action on the hook:
*
* @return Action Added action.
*/
$hook->addAction(callable $callback, int $priority = Priority::NORMAL): Action
public function addAction(callable $callback, int $priority = Priority::NORMAL): Action;
```

Adds action once on the hook:
Expand All @@ -127,7 +123,7 @@ Adds action once on the hook:
*
* @return Action Added action.
*/
$hook->addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action
public function addActionOnce(callable $callback, int $priority = Priority::NORMAL): Action;
```

Runs the added actions for the hook:
Expand All @@ -139,7 +135,7 @@ Runs the added actions for the hook:
*
* @return Action[] Done actions.
*/
$hook->doActions(mixed ...$arguments): Action[]
public function doActions(mixed ...$arguments): array;
```

Checks if the hook has actions:
Expand All @@ -149,7 +145,7 @@ Checks if the hook has actions:
* True if the hook has any action even if the action has been
* done before (recurring actions created with addAction).
*/
$hook->hasActions(): bool
public function hasActions(): bool;
```

Checks if the hook has undone actions:
Expand All @@ -158,7 +154,7 @@ Checks if the hook has undone actions:
/**
* True if the hook has some action left undone.
*/
$hook->hasUndoneActions(): bool
public function hasUndoneActions(): bool;
```

Checks if the actions were done at least once:
Expand All @@ -167,29 +163,27 @@ Checks if the actions were done at least once:
/**
* If doActions was executed at least once.
*/
$hook->hasDoneActions(): bool
public function hasDoneActions(): bool;
```

Gets hook name:

```php
$hook->getName(): string
public function getName(): string;
```

### Priority Class

```php
use Josantonius\Hook\Priority;
```
`Josantonius\Hook\Priority`

Available constants:

```php
Priority::HIGHEST; // 50
Priority::HIGH; // 100
Priority::NORMAL; // 150
Priority::LOW; // 200
Priority::LOWEST; // 250
public const HIGHEST = 50;
public const HIGH = 100;
public const NORMAL = 150;
public const LOW = 200;
public const LOWEST = 250;
```

## Exceptions Used
Expand Down

0 comments on commit 505c22a

Please sign in to comment.