File tree 5 files changed +27
-27
lines changed
tests/testing_environment/data
5 files changed +27
-27
lines changed Original file line number Diff line number Diff line change 20
20
],
21
21
"require" : {
22
22
"php" : " >=7.4.0" ,
23
- "garoevans/php-enum" : " *"
23
+ "garoevans/php-enum" : " *" ,
24
+ "symfony/yaml" : " ^6.3"
24
25
},
25
26
"require-dev" : {
26
27
"phpunit/phpunit" : " *" ,
Original file line number Diff line number Diff line change 11
11
12
12
namespace Exorg \DataCoder ;
13
13
14
+ use Symfony \Component \Yaml \Yaml ;
15
+
14
16
/**
15
17
* YamlDataDecoder.
16
18
* Data decoder for YAML format.
@@ -36,7 +38,7 @@ public function decodeData($data)
36
38
37
39
$ this ->validateData ($ data );
38
40
39
- $ parsedData = \yaml_parse ($ data );
41
+ $ parsedData = Yaml:: parse ($ data );
40
42
41
43
$ parsingSuccessful = ($ parsedData !== null );
42
44
Original file line number Diff line number Diff line change 11
11
12
12
namespace Exorg \DataCoder ;
13
13
14
+ use Symfony \Component \Yaml \Yaml ;
15
+
14
16
/**
15
17
* YamlDataEncoder.
16
18
* Data encoder for YAML format.
@@ -34,7 +36,7 @@ public function encodeData($data)
34
36
{
35
37
$ this ->validateData ($ data );
36
38
37
- $ encodedData = \yaml_emit ($ data );
39
+ $ encodedData = Yaml:: dump ($ data );
38
40
39
41
return $ encodedData ;
40
42
}
Original file line number Diff line number Diff line change 1
- $result = array (
1
+ $result = [
2
2
"firstName" => "John",
3
3
"lastName" => "Smith",
4
4
"isAlive" => true,
5
5
"age" => 25,
6
6
"height_cm" => 167.6,
7
- "address" => array (
7
+ "address" => [
8
8
"streetAddress" => "21 2nd Street",
9
9
"city" => "New York",
10
10
"state" => "NY",
11
11
"postalCode" => "10021-3100",
12
- ) ,
13
- "phoneNumbers" => array (
14
- array (
12
+ ] ,
13
+ "phoneNumbers" => [
14
+ [
15
15
"type" => "home",
16
16
"number" => "212 555-1234",
17
- ) ,
18
- array (
17
+ ] ,
18
+ [
19
19
"type" => "office",
20
20
"number" => "646 555-4567",
21
- ),
22
- ),
23
- "children" => array (
24
- ),
21
+ ],
22
+ ],
23
+ "children" => [],
25
24
"spouse" => null,
26
- ) ;
25
+ ] ;
Original file line number Diff line number Diff line change 1
- ---
2
1
firstName : John
3
2
lastName : Smith
4
3
isAlive : true
5
4
age : 25
6
5
height_cm : 167.6
7
6
address :
8
- streetAddress : 21 2nd Street
9
- city : New York
10
- state : NY
11
- postalCode : 10021-3100
7
+ streetAddress : ' 21 2nd Street'
8
+ city : ' New York'
9
+ state : NY
10
+ postalCode : 10021-3100
12
11
phoneNumbers :
13
- - type : home
14
- number : 212 555-1234
15
- - type : office
16
- number : 646 555-4567
17
- children : []
18
- spouse : ~
19
- ...
12
+ - { type: home, number: '212 555-1234' }
13
+ - { type: office, number: '646 555-4567' }
14
+ children : { }
15
+ spouse : null
You can’t perform that action at this time.
0 commit comments