Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 34 additions & 38 deletions .github/lang/es-ES/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ Biblioteca PHP para el manejo de cookies.

## Requisitos

Esta biblioteca es compatible con las versiones de PHP: 8.1.
- Sistema operativo: Linux.

- Versiones de PHP: 8.1 | 8.2.

## Instalación

Expand Down Expand Up @@ -63,9 +65,7 @@ git clone https://github.com/josantonius/php-cookie.git

### Clase Cookie

```php
use Josantonius\Cookie\Cookie;
```
`Josantonius\Cookie\Cookie`

Establece las opciones de las cookies:

Expand All @@ -88,15 +88,14 @@ Establece las opciones de las cookies:
* @see https://www.php.net/manual/en/datetime.formats.php for date formats.
* @see https://www.php.net/manual/en/function.setcookie.php for more information.
*/

$cookie = new Cookie(
string $domain = '',
int|string|DateTime $expires = 0,
bool $httpOnly = false,
string $path = '/',
bool $raw = false,
null|string $sameSite = null,
bool $secure = false
public function __construct(
private string $domain = '',
private int|string|DateTime $expires = 0,
private bool $httpOnly = false,
private string $path = '/',
private bool $raw = false,
private null|string $sameSite = null,
private bool $secure = false
);
```

Expand All @@ -107,11 +106,11 @@ Establece una cookie por nombre:
* @throws CookieException si las cabeceras ya han sido enviadas.
* @throws CookieException si falla el análisis de la cadena de fecha/hora.
*/
$cookie->set(
public function set(
string $name,
mixed $value,
null|int|string|DateTime $expires = null
): void
): void;
```

Establece varias cookies a la vez:
Expand All @@ -122,10 +121,10 @@ Establece varias cookies a la vez:
*
* @throws CookieException si las cabeceras ya han sido enviadas.
*/
$cookie->replace(
public function replace(
array $data,
null|int|string|DateTime $expires = null
): void
): void;
```

Obtiene una cookie por su nombre:
Expand All @@ -134,19 +133,19 @@ Obtiene una cookie por su nombre:
/**
* Opcionalmente define un valor por defecto cuando la cookie no existe.
*/
$cookie->get(string $name, mixed $default = null): mixed
public function get(string $name, mixed $default = null): mixed;
```

Obtiene todas las cookies:

```php
$cookie->all(): array
public function all(): array;
```

Comprueba si existe una cookie:

```php
$cookie->has(string $name): bool
public function has(string $name): bool;
```

Elimina una cookie por su nombre y devuelve su valor:
Expand All @@ -157,7 +156,7 @@ Elimina una cookie por su nombre y devuelve su valor:
*
* @throws CookieException si las cabeceras ya han sido enviadas.
*/
$cookie->pull(string $name, mixed $default = null): mixed
public function pull(string $name, mixed $default = null): mixed;
```

Borra una cookie por su nombre:
Expand All @@ -167,14 +166,12 @@ Borra una cookie por su nombre:
* @throws CookieException si las cabeceras ya han sido enviadas.
* @throws CookieException si falla el análisis de la cadena de fecha/hora.
*/
$cookie->remove(string $name): void
public function remove(string $name): void;
```

### Fachada Cookie

```php
use Josantonius\Cookie\Facades\Cookie;
```
`Josantonius\Cookie\Facades\Cookie`

Establece las opciones de las cookies:

Expand All @@ -197,16 +194,15 @@ Establece las opciones de las cookies:
* @see https://www.php.net/manual/en/datetime.formats.php for date formats.
* @see https://www.php.net/manual/en/function.setcookie.php for more information.
*/

Cookie::options(
public static function options(
string $domain = '',
int|string|DateTime $expires = 0,
bool $httpOnly = false,
string $path = '/',
bool $raw = false,
null|string $sameSite = null,
bool $secure = false
);
): void;
```

Establece una cookie por nombre:
Expand All @@ -216,11 +212,11 @@ Establece una cookie por nombre:
* @throws CookieException si las cabeceras ya han sido enviadas.
* @throws CookieException si falla el análisis de la cadena de fecha/hora.
*/
Cookie::set(
public static function set(
string $name,
mixed $value,
null|int|string|DateTime $expires = null
): void
): void;
```

Establece varias cookies a la vez:
Expand All @@ -231,10 +227,10 @@ Establece varias cookies a la vez:
*
* @throws CookieException si las cabeceras ya han sido enviadas.
*/
Cookie::replace(
public static function replace(
array $data,
null|int|string|DateTime $expires = null
): void
): void;
```

Obtiene una cookie por su nombre:
Expand All @@ -243,19 +239,19 @@ Obtiene una cookie por su nombre:
/**
* Opcionalmente define un valor por defecto cuando la cookie no existe.
*/
Cookie::get(string $name, mixed $default = null): mixed
public static function get(string $name, mixed $default = null): mixed;
```

Obtiene todas las cookies:

```php
Cookie::all(): array
public static function all(): array;
```

Comprueba si existe una cookie:

```php
Cookie::has(string $name): bool
public static function has(string $name): bool;
```

Elimina una cookie por su nombre y devuelve su valor:
Expand All @@ -266,7 +262,7 @@ Elimina una cookie por su nombre y devuelve su valor:
*
* @throws CookieException si las cabeceras ya han sido enviadas.
*/
Cookie::pull(string $name, mixed $default = null): mixed
public static function pull(string $name, mixed $default = null): mixed;
```

Borra una cookie por su nombre:
Expand All @@ -276,7 +272,7 @@ Borra una cookie por su nombre:
* @throws CookieException si las cabeceras ya han sido enviadas.
* @throws CookieException si falla el análisis de la cadena de fecha/hora.
*/
Cookie::remove(string $name): void
public static function remove(string $name): void;
```

## Excepciones utilizadas
Expand All @@ -285,7 +281,7 @@ Cookie::remove(string $name): void
use Josantonius\Cookie\Exceptions\CookieException;
```

## Usage
## Uso

Ejemplos de uso de esta biblioteca:

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
system: ['ubuntu-latest']
php:
- '8.1'
- '8.2'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# CHANGELOG

## [v2.0.6](https://github.com/josantonius/php-cookie/releases/tag/v2.0.6) (2022-09-29)

* The notation type in the test function names has been changed from camel to snake case for readability.

* Functions were added to document the methods and avoid confusion.

* Disabled the ´CamelCaseMethodName´ rule in ´phpmd.xml´ to avoid warnings about function names in tests.

* The alignment of the asterisks in the comments has been fixed.

* Tests for Windows have been added.

* Tests for PHP 8.2 have been added.

## [2.0.5](https://github.com/josantonius/php-cookie/releases/tag/2.0.5) (2022-08-11)

* Improved documentation.
Expand Down
Loading