Skip to content

Commit fac2f6e

Browse files
committed
Source code refactoring.
1 parent e1396f1 commit fac2f6e

File tree

10 files changed

+345
-316
lines changed

10 files changed

+345
-316
lines changed

.editorconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
indent_style = space
10+
indent_size = 4
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.{md,htm,html,blade.php}]
15+
insert_final_newline = false
16+
trim_trailing_whitespace = false
17+
18+
[*.{min.css,min.js}]
19+
insert_final_newline = false
20+
21+
[*.{yml,yaml}]
22+
indent_size = 2
23+
24+
[docker-compose.yml]
25+
indent_size = 4

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
# Auto detect text files and perform LF normalization
22
* text=auto
3+
4+
/.github export-ignore
5+
/tests export-ignore
6+
.editorconfig export-ignore
7+
.gitattributes export-ignore
8+
.gitignore export-ignore
9+
.php-cs-fixer.dist.php export-ignore
10+
.travis.yml export-ignore
11+
phpunit.xml export-ignore

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/vendor
2-
composer.phar
3-
composer.lock
2+
.phpunit.result.cache
43
.php_cs.cache
4+
.php-cs-fixer.cache
55
.DS_Store
6+
composer.phar
7+
composer.lock

README.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
[![Build Status](https://api.travis-ci.org/JackieDo/Xml-Array.svg?branch=master)](https://travis-ci.org/JackieDo/Xml-Array)
33
[![Total Downloads](https://poser.pugx.org/jackiedo/xml-array/downloads)](https://packagist.org/packages/jackiedo/xml-array)
44
[![Latest Stable Version](https://poser.pugx.org/jackiedo/xml-array/v/stable)](https://packagist.org/packages/jackiedo/xml-array)
5-
[![Latest Unstable Version](https://poser.pugx.org/jackiedo/xml-array/v/unstable)](https://packagist.org/packages/jackiedo/xml-array)
65
[![License](https://poser.pugx.org/jackiedo/xml-array/license)](https://packagist.org/packages/jackiedo/xml-array)
76

87
The conversion between xml and array becomes easier than ever. This package provides some very simple classes to convert XML to array and back.
@@ -15,38 +14,46 @@ The conversion between xml and array becomes easier than ever. This package prov
1514
# Overview
1615
Look at one of the following sessions to learn more about this package.
1716

18-
* [Installation](#installation)
19-
* [Basic usage](#basic-usage)
17+
- [Xml-Array](#xml-array)
18+
- [Features of this package](#features-of-this-package)
19+
- [Overview](#overview)
20+
- [Installation](#installation)
21+
- [Basic usage](#basic-usage)
2022
- [Convert XML to array](#convert-xml-to-array)
2123
- [Convert XML to Json](#convert-xml-to-json)
2224
- [Convert array to XML](#convert-array-to-xml)
2325
- [Convert array to DOM](#convert-array-to-dom)
24-
* [Advanced usage](#advanced-usage)
26+
- [Advanced usage](#advanced-usage)
2527
- [Set configuration](#set-configuration)
28+
- [Method 1](#method-1)
29+
- [Method 2](#method-2)
30+
- [Method 3](#method-3)
2631
- [Get configuration](#get-configuration)
2732
- [Default configuration](#default-configuration)
28-
* [License](#license)
33+
- [For Xml2Array](#for-xml2array)
34+
- [For Array2Xml](#for-array2xml)
35+
- [License](#license)
2936

3037
## Installation
3138
You can install this package through [Composer](https://getcomposer.org).
3239

3340
```shell
34-
composer require jackiedo/xml-array
41+
$ composer require jackiedo/xml-array
3542
```
3643

3744
## Basic usage
3845

3946
### Convert XML to array
4047

41-
###### Syntax:
48+
**Syntax**:
4249

4350
```
4451
array Xml2Array::convert(DOMDocument|SimpleXMLElement|string $inputXML)->toArray();
4552
```
4653

4754
> **Note:** The input XML can be one of types DOMDocument object, SimpleXMLElement object or well-formed XML string.
4855
49-
###### Example 1 (Convert from XML string):
56+
**Example 1** - _(Convert from XML string)_:
5057

5158
```php
5259
use Jackiedo\XmlArray\Xml2Array;
@@ -135,7 +142,7 @@ $array = [
135142
]
136143
```
137144

138-
###### Example 2 (Convert form XML object, such as SimpleXMLElement):
145+
**Example 2** - _(Convert form XML object, such as SimpleXMLElement)_:
139146

140147
```php
141148
use Jackiedo\XmlArray\Xml2Array;
@@ -331,27 +338,27 @@ $array = [
331338

332339
### Convert XML to Json
333340

334-
###### Syntax:
341+
**Syntax**:
335342

336343
```
337344
string Xml2Array::convert(DOMDocument|SimpleXMLElement|string $inputXML)->toJson([int $options = 0]);
338345
```
339346

340-
###### Example 3:
347+
**Example 3**:
341348

342349
```php
343350
$jsonString = Xml2Array::convert($xmlString)->toJson(JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
344351
```
345352

346353
### Convert array to XML
347354

348-
###### Syntax:
355+
**Syntax**:
349356

350357
```
351358
string Array2Xml::convert(array $array)->toXml([bool $prettyOutput = false]);
352359
```
353360

354-
###### Example 4:
361+
**Example 4**:
355362

356363
```php
357364
use Jackiedo\XmlArray\Array2Xml;
@@ -363,13 +370,13 @@ $xmlString = Array2Xml::convert($array)->toXml(true);
363370

364371
### Convert array to DOM
365372

366-
###### Syntax:
373+
**Syntax**:
367374

368375
```
369376
DOMDocument Array2Xml::convert(array $array)->toDom();
370377
```
371378

372-
###### Example 5:
379+
**Example 5**:
373380

374381
```php
375382
$domObject = Array2Xml::convert($array)->toDom();
@@ -380,7 +387,7 @@ $domObject = Array2Xml::convert($array)->toDom();
380387
### Set configuration
381388
You can set configuration for conversion process with one of following methods:
382389

383-
###### Method 1:
390+
#### Method 1
384391

385392
```php
386393
...
@@ -398,14 +405,14 @@ $xml = Array2Xml::convert($inputArray, $config)->toXml();
398405

399406
> **Note**: Configuration is an array of parameters. For more details, see section [Default configuration](#default-configuration).
400407
401-
###### Method 2:
408+
#### Method 2
402409

403410
```php
404411
$converter = new Xml2Array($config);
405412
$array = $converter->convertFrom($inputXml)->toArray();
406413
```
407414

408-
###### Method 3:
415+
#### Method 3
409416

410417
```php
411418
$converter = new Xml2Array;
@@ -421,7 +428,7 @@ $config = $converter->getConfig();
421428

422429
### Default configuration
423430

424-
###### For Xml2Array
431+
#### For Xml2Array
425432

426433
```php
427434
$defaultConfig = [
@@ -434,7 +441,7 @@ $defaultConfig = [
434441
];
435442
```
436443

437-
###### For Array2Xml
444+
#### For Array2Xml
438445

439446
```php
440447
$defaultConfig = [
@@ -447,5 +454,5 @@ $defaultConfig = [
447454
];
448455
```
449456

450-
## License
457+
# License
451458
[MIT](LICENSE) © Jackie Do

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"autoload": {
3434
"psr-4": {
35-
"Jackiedo\\XmlArray\\": "src"
35+
"Jackiedo\\XmlArray\\": "src/"
3636
}
3737
},
3838
"minimum-stability": "stable"

0 commit comments

Comments
 (0)