Skip to content

Commit 6678011

Browse files
committed
docs: upgrade to the v2.0.6 version
Closes #22
1 parent 3480296 commit 6678011

File tree

2 files changed

+202
-16
lines changed

2 files changed

+202
-16
lines changed

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

Lines changed: 101 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,42 @@ git clone https://github.com/josantonius/php-json.git
6363

6464
`Josantonius\Json\Json`
6565

66+
Comprueba si existe un archivo local o remoto.
67+
68+
```php
69+
public function exists(): bool;
70+
```
71+
6672
Obtener el contenido del archivo JSON:
6773

6874
```php
6975
/**
70-
* @throws CreateDirectoryException if there is an error when creating a directory.
71-
* @throws CreateFileException if there is an error when creating a file.
72-
* @throws JsonErrorException if there is an error when parsing a JSON file.
76+
* @throws GetFileException if there is an error when getting a file.
77+
* @throws JsonErrorException if there is an error when parsing a JSON file.
7378
*/
7479
public function get(): array;
7580
```
7681

82+
Obtiene la ruta o URL del archivo JSON.
83+
84+
```php
85+
public function getFilepath(): string;
86+
```
87+
7788
Establecer el contenido del archivo JSON:
7889

7990
```php
8091
/**
8192
* @throws CreateFileException if there is an error when creating a file.
82-
* @throws JsonErrorException if there is an error when parsing a JSON file.
8393
* @throws UnavailableMethodException if the method is not available.
8494
*/
85-
public function set(array|object $content): void;
95+
public function set(array|object $content = []): void;
8696
```
8797

8898
Fusionar en el archivo JSON:
8999

90100
```php
91101
/**
92-
* @throws CreateFileException if there is an error when creating a file.
93102
* @throws GetFileException if there is an error when getting a file.
94103
* @throws JsonErrorException if there is an error when parsing a JSON file.
95104
* @throws UnavailableMethodException if the method is not available.
@@ -101,7 +110,6 @@ Incluir en el archivo JSON:
101110

102111
```php
103112
/**
104-
* @throws CreateFileException if there is an error when creating a file.
105113
* @throws GetFileException if there is an error when getting a file.
106114
* @throws JsonErrorException if there is an error when parsing a JSON file.
107115
* @throws UnavailableMethodException if the method is not available.
@@ -112,7 +120,6 @@ public function push(array|object $content): array;
112120
## Excepciones utilizadas
113121

114122
```php
115-
use Josantonius\Json\Exceptions\CreateDirectoryException;
116123
use Josantonius\Json\Exceptions\CreateFileException;
117124
use Josantonius\Json\Exceptions\GetFileException;
118125
use Josantonius\Json\Exceptions\JsonErrorException;
@@ -123,6 +130,30 @@ use Josantonius\Json\Exceptions\UnavailableMethodException;
123130

124131
Ejemplo de uso para esta biblioteca:
125132

133+
### Comprueba si existe un archivo local
134+
135+
**`index.php`**
136+
137+
```php
138+
use Josantonius\Json\Json;
139+
140+
$json = new Json('file.json');
141+
142+
$json->exists(); // bool
143+
```
144+
145+
### Comprueba si existe un archivo remoto
146+
147+
**`index.php`**
148+
149+
```php
150+
use Josantonius\Json\Json;
151+
152+
$json = new Json('https://example.com/file.json');
153+
154+
$json->exists(); // bool
155+
```
156+
126157
### Obtener el contenido del archivo
127158

128159
**`file.json`**
@@ -143,6 +174,68 @@ $json = new Json('file.json');
143174
$json->get(); // ['foo' => 'bar']
144175
```
145176

177+
### Obtener el contenido del archivo desde una URL
178+
179+
**`https://example.com/file.json`**
180+
181+
```json
182+
{
183+
"foo": "bar"
184+
}
185+
```
186+
187+
**`index.php`**
188+
189+
```php
190+
use Josantonius\Json\Json;
191+
192+
$json = new Json('https://example.com/file.json');
193+
194+
$json->get(); // ['foo' => 'bar']
195+
```
196+
197+
### Obtiene la ruta del archivo JSON
198+
199+
**`index.php`**
200+
201+
```php
202+
use Josantonius\Json\Json;
203+
204+
$json = new Json('file.json');
205+
206+
$json->getFilepath(); // 'file.json'
207+
```
208+
209+
### Obtiene la URL del archivo JSON remoto
210+
211+
**`index.php`**
212+
213+
```php
214+
use Josantonius\Json\Json;
215+
216+
$json = new Json('https://example.com/file.json');
217+
218+
$json->getFilepath(); // 'https://example.com/file.json'
219+
```
220+
221+
### Establecer una matriz vacía en el contenido del archivo JSON
222+
223+
**`index.php`**
224+
225+
```php
226+
use Josantonius\Json\Json;
227+
228+
$json = new Json('file.json');
229+
230+
$json->set();
231+
```
232+
233+
**`file.json`**
234+
235+
```json
236+
[]
237+
```
238+
146239
### Establecer el contenido del archivo
147240

148241
**`index.php`**

README.md

Lines changed: 101 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,42 @@ git clone https://github.com/josantonius/php-json.git
6363

6464
`Josantonius\Json\Json`
6565

66+
Check whether a local or remote file exists.
67+
68+
```php
69+
public function exists(): bool;
70+
```
71+
6672
Get JSON file contents:
6773

6874
```php
6975
/**
70-
* @throws CreateDirectoryException if there is an error when creating a directory.
71-
* @throws CreateFileException if there is an error when creating a file.
72-
* @throws JsonErrorException if there is an error when parsing a JSON file.
76+
* @throws GetFileException if there is an error when getting a file.
77+
* @throws JsonErrorException if there is an error when parsing a JSON file.
7378
*/
7479
public function get(): array;
7580
```
7681

82+
Get the path or URL of the JSON file.
83+
84+
```php
85+
public function getFilepath(): string;
86+
```
87+
7788
Set the content of the JSON file:
7889

7990
```php
8091
/**
8192
* @throws CreateFileException if there is an error when creating a file.
82-
* @throws JsonErrorException if there is an error when parsing a JSON file.
8393
* @throws UnavailableMethodException if the method is not available.
8494
*/
85-
public function set(array|object $content): void;
95+
public function set(array|object $content = []): void;
8696
```
8797

8898
Merge into JSON file:
8999

90100
```php
91101
/**
92-
* @throws CreateFileException if there is an error when creating a file.
93102
* @throws GetFileException if there is an error when getting a file.
94103
* @throws JsonErrorException if there is an error when parsing a JSON file.
95104
* @throws UnavailableMethodException if the method is not available.
@@ -101,7 +110,6 @@ Push on the JSON file:
101110

102111
```php
103112
/**
104-
* @throws CreateFileException if there is an error when creating a file.
105113
* @throws GetFileException if there is an error when getting a file.
106114
* @throws JsonErrorException if there is an error when parsing a JSON file.
107115
* @throws UnavailableMethodException if the method is not available.
@@ -112,7 +120,6 @@ public function push(array|object $content): array;
112120
## Exceptions Used
113121

114122
```php
115-
use Josantonius\Json\Exceptions\CreateDirectoryException;
116123
use Josantonius\Json\Exceptions\CreateFileException;
117124
use Josantonius\Json\Exceptions\GetFileException;
118125
use Josantonius\Json\Exceptions\JsonErrorException;
@@ -123,6 +130,30 @@ use Josantonius\Json\Exceptions\UnavailableMethodException;
123130

124131
Example of use for this library:
125132

133+
### Check whether a local file exists
134+
135+
**`index.php`**
136+
137+
```php
138+
use Josantonius\Json\Json;
139+
140+
$json = new Json('file.json');
141+
142+
$json->exists(); // bool
143+
```
144+
145+
### Check whether a remote file exists
146+
147+
**`index.php`**
148+
149+
```php
150+
use Josantonius\Json\Json;
151+
152+
$json = new Json('https://example.com/file.json');
153+
154+
$json->exists(); // bool
155+
```
156+
126157
### Get the JSON file contents
127158

128159
**`file.json`**
@@ -143,6 +174,68 @@ $json = new Json('file.json');
143174
$json->get(); // ['foo' => 'bar']
144175
```
145176

177+
### Get the JSON file contents from URL
178+
179+
**`https://example.com/file.json`**
180+
181+
```json
182+
{
183+
"foo": "bar"
184+
}
185+
```
186+
187+
**`index.php`**
188+
189+
```php
190+
use Josantonius\Json\Json;
191+
192+
$json = new Json('https://example.com/file.json');
193+
194+
$json->get(); // ['foo' => 'bar']
195+
```
196+
197+
### Get the path of the JSON file
198+
199+
**`index.php`**
200+
201+
```php
202+
use Josantonius\Json\Json;
203+
204+
$json = new Json('file.json');
205+
206+
$json->getFilepath(); // 'file.json'
207+
```
208+
209+
### Get the URL of the remote JSON file
210+
211+
**`index.php`**
212+
213+
```php
214+
use Josantonius\Json\Json;
215+
216+
$json = new Json('https://example.com/file.json');
217+
218+
$json->getFilepath(); // 'https://example.com/file.json'
219+
```
220+
221+
### Set an empty array in the JSON file contents
222+
223+
**`index.php`**
224+
225+
```php
226+
use Josantonius\Json\Json;
227+
228+
$json = new Json('file.json');
229+
230+
$json->set();
231+
```
232+
233+
**`file.json`**
234+
235+
```json
236+
[]
237+
```
238+
146239
### Set the JSON file contents
147240

148241
**`index.php`**

0 commit comments

Comments
 (0)