Skip to content

Commit f38b79b

Browse files
committed
docs: improve documentation
1 parent 06a0249 commit f38b79b

File tree

2 files changed

+154
-120
lines changed

2 files changed

+154
-120
lines changed

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

Lines changed: 77 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ Biblioteca PHP para la gestión de archivos JSON.
1717

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

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

61-
Métodos disponibles en esta biblioteca:
62-
63-
### Obtener el contenido del archivo JSON
62+
### Clase Json
6463

6564
```php
66-
$json->get(): array
65+
use Josantonius\Json\Json;
6766
```
6867

69-
**@throws** `CreateDirectoryException` si no se puede crear el directorio.
70-
71-
**@throws** `CreateFileException` si no se puede crear el archivo.
68+
Obtener el contenido del archivo JSON:
7269

73-
**@throws** `JsonErrorException` si hay un error al analizar un archivo JSON.
70+
```php
71+
/**
72+
* @throws CreateDirectoryException if there is an error when creating a directory.
73+
* @throws CreateFileException if there is an error when creating a file.
74+
* @throws JsonErrorException if there is an error when parsing a JSON file.
75+
*/
76+
$json->get(): array
77+
```
7478

75-
### Establecer el contenido del archivo JSON
79+
Establecer el contenido del archivo JSON:
7680

7781
```php
82+
/**
83+
* @throws CreateFileException if there is an error when creating a file.
84+
* @throws JsonErrorException if there is an error when parsing a JSON file.
85+
* @throws UnavailableMethodException if the method is not available.
86+
*/
7887
$json->set(array|object $content): void
7988
```
8089

81-
**@throws** `CreateFileException` si no se puede crear el archivo.
82-
83-
**@throws** `JsonErrorException` si hay un error al analizar un archivo JSON.
84-
85-
**@throws** `UnavailableMethodException` si el método no está disponible.
86-
87-
### Fusionar en el archivo JSON
90+
Fusionar en el archivo JSON:
8891

8992
```php
93+
/**
94+
* @throws CreateFileException if there is an error when creating a file.
95+
* @throws GetFileException if there is an error when getting a file.
96+
* @throws JsonErrorException if there is an error when parsing a JSON file.
97+
* @throws UnavailableMethodException if the method is not available.
98+
*/
9099
$json->merge(array|object $content): array
91100
```
92101

93-
**@throws** `CreateFileException` si no se puede crear el archivo.
94-
95-
**@throws** `GetFileException` si no se puede obtener el archivo.
96-
97-
**@throws** `JsonErrorException` si hay un error al analizar un archivo JSON.
98-
99-
**@throws** `UnavailableMethodException` si el método no está disponible.
100-
101-
### Incluir en el archivo JSON
102+
Incluir en el archivo JSON:
102103

103104
```php
105+
/**
106+
* @throws CreateFileException if there is an error when creating a file.
107+
* @throws GetFileException if there is an error when getting a file.
108+
* @throws JsonErrorException if there is an error when parsing a JSON file.
109+
* @throws UnavailableMethodException if the method is not available.
110+
*/
104111
$json->push(array|object $content): array
105112
```
106113

107-
**@throws** `CreateFileException` si no se puede crear el archivo.
108-
109-
**@throws** `GetFileException` si no se puede obtener el archivo.
110-
111-
**@throws** `JsonErrorException` si hay un error al analizar un archivo JSON.
112-
113-
**@throws** `UnavailableMethodException` si el método no está disponible.
114-
115-
## Cómo empezar
116-
117-
Para utilizar esta biblioteca con **Composer**:
114+
## Excepciones utilizadas
118115

119116
```php
120-
require __DIR__ . '/vendor/autoload.php';
121-
122-
use josantonius\Json\Json;
123-
```
124-
125-
```php
126-
$json = new Json('path/to/file.json');
127-
128-
# Si el archivo no existe, se creará.
129-
```
130-
131-
O
132-
133-
```php
134-
$json = new Json('https://site.com/file.json');
135-
136-
# Cuando el archivo JSON se obtiene desde una URL, sólo estará disponible el método "get".
117+
use Josantonius\Json\Exceptions\CreateDirectoryException;
118+
use Josantonius\Json\Exceptions\CreateFileException;
119+
use Josantonius\Json\Exceptions\GetFileException;
120+
use Josantonius\Json\Exceptions\JsonErrorException;
121+
use Josantonius\Json\Exceptions\UnavailableMethodException;
137122
```
138123

139124
## Uso
@@ -142,26 +127,38 @@ Ejemplo de uso para esta biblioteca:
142127

143128
### Obtener el contenido del archivo
144129

130+
**`file.json`**
131+
145132
```json
146133
{
147134
"foo": "bar"
148135
}
149136
```
150137

151-
```php
152-
$json->get();
153-
```
138+
**`index.php`**
154139

155140
```php
156-
['foo' => 'bar']
141+
use Josantonius\Json\Json;
142+
143+
$json = new Json('file.json');
144+
145+
$json->get(); // ['foo' => 'bar']
157146
```
158147

159148
### Establecer el contenido del archivo
160149

150+
**`index.php`**
151+
161152
```php
153+
use Josantonius\Json\Json;
154+
155+
$json = new Json('file.json');
156+
162157
$json->set(['foo' => 'bar']);
163158
```
164159

160+
**`file.json`**
161+
165162
```json
166163
{
167164
"foo": "bar"
@@ -170,16 +167,26 @@ $json->set(['foo' => 'bar']);
170167

171168
### Fusionar en el archivo
172169

170+
**`file.json`**
171+
173172
```json
174173
{
175174
"foo": "bar"
176175
}
177176
```
178177

178+
**`index.php`**
179+
179180
```php
181+
use Josantonius\Json\Json;
182+
183+
$json = new Json('file.json');
184+
180185
$json->merge(['bar' => 'foo']);
181186
```
182187

188+
**`file.json`**
189+
183190
```json
184191
{
185192
"foo": "bar",
@@ -189,6 +196,8 @@ $json->merge(['bar' => 'foo']);
189196

190197
### Incluir en el archivo
191198

199+
**`file.json`**
200+
192201
```json
193202
[
194203
{
@@ -197,10 +206,18 @@ $json->merge(['bar' => 'foo']);
197206
]
198207
```
199208

209+
**`index.php`**
210+
200211
```php
212+
use Josantonius\Json\Json;
213+
214+
$json = new Json('file.json');
215+
201216
$json->push(['name' => 'bar']);
202217
```
203218

219+
**`file.json`**
220+
204221
```json
205222
[
206223
{

0 commit comments

Comments
 (0)