Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from chubbyphp/use-chubbyphp-decode-encode
use-chubbyphp-decode-encode
- Loading branch information
Showing
25 changed files
with
329 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,5 @@ | ||
# Decoder | ||
|
||
```php | ||
<?php | ||
Use [Decoder][1] from chubbyphp/chubbyphp-decode-encode. | ||
|
||
use Chubbyphp\Deserialization\Decoder\Decoder; | ||
use Chubbyphp\Deserialization\Decoder\JsonTypeDecoder; | ||
use Chubbyphp\Deserialization\Decoder\JsonxTypeDecoder; | ||
use Chubbyphp\Deserialization\Decoder\UrlEncodedTypeDecoder; | ||
use Chubbyphp\Deserialization\Decoder\XmlTypeDecoder; | ||
use Chubbyphp\Deserialization\Decoder\YamlTypeDecoder; | ||
|
||
$decoder = new Decoder([ | ||
new JsonTypeDecoder(), | ||
new JsonxTypeDecoder(), | ||
new UrlEncodedTypeDecoder(), | ||
new XmlTypeDecoder(), | ||
new YamlTypeDecoder() | ||
]); | ||
|
||
print_r($decoder->getContentTypes()); | ||
//[ | ||
// 'application/json', | ||
// 'application/jsonx+xml', | ||
// 'application/x-www-form-urlencoded', | ||
// 'application/xml', | ||
// 'application/x-yaml' | ||
//] | ||
|
||
print_r($decoder->decode( | ||
'{"name": "php"}', | ||
'application/json' | ||
)); | ||
// ['name' => 'php'] | ||
``` | ||
[1]: https://github.com/chubbyphp/chubbyphp-decode-encode/blob/master/doc/Decoder/Decoder.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
# JsonTypeDecoder | ||
|
||
```php | ||
<?php | ||
Use [JsonTypeDecoder][1] from chubbyphp/chubbyphp-decode-encode. | ||
|
||
use Chubbyphp\Deserialization\Decoder\JsonTypeDecoder; | ||
|
||
$decoderType = new JsonTypeDecoder(); | ||
|
||
echo $decoderType->getContentType(); | ||
// 'application/json' | ||
|
||
print_r($decoderType->decode('{"name": "php"}')); | ||
// ['name' => 'php'] | ||
``` | ||
[1]: https://github.com/chubbyphp/chubbyphp-decode-encode/blob/master/doc/Decoder/JsonTypeDecoder.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
# JsonxTypeDecoder | ||
|
||
```php | ||
<?php | ||
Use [JsonxTypeDecoder][1] from chubbyphp/chubbyphp-decode-encode. | ||
|
||
use Chubbyphp\Deserialization\Decoder\JsonxTypeDecoder; | ||
|
||
$decoderType = new JsonxTypeDecoder(); | ||
|
||
echo $decoderType->getContentType(); | ||
// 'application/jsonx+xml' | ||
|
||
print_r($decoderType->decode('<json:object><json:string name="name">php</json:string></json:object>')); | ||
// ['name' => 'php'] | ||
``` | ||
[1]: https://github.com/chubbyphp/chubbyphp-decode-encode/blob/master/doc/Decoder/JsonxTypeDecoder.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
# UrlEncodedTypeDecoder | ||
|
||
```php | ||
<?php | ||
Use [UrlEncodedTypeDecoder][1] from chubbyphp/chubbyphp-decode-encode. | ||
|
||
use Chubbyphp\Deserialization\Decoder\UrlEncodedTypeDecoder; | ||
|
||
$decoderType = new UrlEncodedTypeDecoder(); | ||
|
||
echo $decoderType->getContentType(); | ||
// 'application/x-www-form-urlencoded' | ||
|
||
print_r($decoderType->decode('name=php')); | ||
// ['name' => 'php'] | ||
``` | ||
[1]: https://github.com/chubbyphp/chubbyphp-decode-encode/blob/master/doc/Decoder/UrlEncodedTypeDecoder.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
# XmlTypeDecoder (alias for Jsonx) | ||
# XmlTypeDecoder | ||
|
||
```php | ||
<?php | ||
Use [XmlTypeDecoder][1] from chubbyphp/chubbyphp-decode-encode. | ||
|
||
use Chubbyphp\Deserialization\Decoder\XmlTypeDecoder; | ||
|
||
$decoderType = new XmlTypeDecoder(); | ||
|
||
echo $decoderType->getContentType(); | ||
// 'application/xml' | ||
|
||
print_r($decoderType->decode('<json:object><json:string name="name">php</json:string></json:object>')); | ||
// ['name' => 'php'] | ||
``` | ||
[1]: https://github.com/chubbyphp/chubbyphp-decode-encode/blob/master/doc/Decoder/XmlTypeDecoder.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
# YamlTypeDecoder | ||
|
||
```php | ||
<?php | ||
Use [YamlTypeDecoder][1] from chubbyphp/chubbyphp-decode-encode. | ||
|
||
use Chubbyphp\Deserialization\Decoder\YamlTypeDecoder; | ||
|
||
$decoderType = new YamlTypeDecoder(); | ||
|
||
echo $decoderType->getContentType(); | ||
// 'application/x-yaml' | ||
|
||
print_r($decoderType->decode('name: php')); | ||
// ['name' => 'php'] | ||
``` | ||
[1]: https://github.com/chubbyphp/chubbyphp-decode-encode/blob/master/doc/Decoder/YamlTypeDecoder.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.